Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile due to narrowing conversion #34

Closed
wouterbeek opened this issue Jun 24, 2016 · 16 comments
Closed

Cannot compile due to narrowing conversion #34

wouterbeek opened this issue Jun 24, 2016 · 16 comments
Assignees
Labels

Comments

@wouterbeek
Copy link
Contributor

Compiling hdt-lib using GCC 6.1.1 gives me the following warnings:

static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-1’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
 Tsucc RMQ_succinct::HighestBitsSet[8] = {~0, ~1, ~3, ~7, ~15, ~31, ~63, ~127};
                                                                             ^
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-2’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-4’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-8’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-16’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-32’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-64’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-128’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
Makefile:35: recipe for target 'static/suffixtree/RMQ_succinct.o' failed
make[3]: *** [static/suffixtree/RMQ_succinct.o] Error 1
Makefile:39: recipe for target 'all' failed
make[2]: *** [all] Error 2
Makefile:13: recipe for target 'libcompact' failed
make[1]: *** [libcompact] Error 2
make[1]: Leaving directory '/home/wbeek/Git/hdt-cpp/libcds-v1.0.12'
Makefile:63: recipe for target 'all' failed
make: *** [all] Error 2

In order to compile the library I have to make the following change in two files. From:

const DTsucc RMQ_succinct_lcp::HighestBitsSet[8] = {~0, ~1, ~3, ~7, ~15, ~31, ~63, ~127};

To:

const DTsucc RMQ_succinct_lcp::HighestBitsSet[8] = {static_cast<DTsucc>(~0), static_cast<DTsucc>(~1), static_cast<DTsucc>(~3), static_cast<DTsucc>(~7), static_cast<DTsucc>(~15), static_cast<DTsucc>(~31), static_cast<DTsucc>(~63), static_cast<DTsucc>(~127)};

Since my C++ skills are non-existent, a capable programmer may fix this in a less hacky way :-P

@artob artob self-assigned this Jun 24, 2016
@artob artob added the bug label Jun 24, 2016
@artob
Copy link
Contributor

artob commented Jun 24, 2016

Thanks, @wouterbeek. I'll take a look in a bit.

@RubenVerborgh
Copy link
Member

@wouterbeek Any idea what's special about your version? I tried compiling with various gcc versions, and it worked: https://travis-ci.org/rdfhdt/hdt-cpp/jobs/190402735

@RubenVerborgh
Copy link
Member

@wouterbeek Does 4f6ecce solve your problem?

@wouterbeek
Copy link
Contributor Author

@RubenVerborgh Removing the 'if-then-else' indeed fixes the issue for me! In fact, if I just remove the 'else' part on branch stable (I'm still using stable) I'm already able to compile.

I do not understand how I can end up in the 'else' part all of the time, because the 'if' conditions seems to be set directly before the 'if-then-else' statement?

PS: In commit c82d90d you have added a flag that is not recognized on my system (Ubuntu 16.10, GCC 6.2.0):

cc1plus: warning: unrecognized command line option ‘-Wno-unknown-warning-option’

@RubenVerborgh
Copy link
Member

It was actually the addition of -Wno-narrowing that was supposed to fix it 😕 Strange, I don't see how you're hitting the else part either.

The -Wno-unknown-warning-option's purpose was precisely to ignore unknown warning flags, so that's ironic. But as long as it compiles, I'll keep it, because it was necessary for some other systems unfortunately.

I'll merge this to master then. I think we should change names from stable to master and master to develop, because “stable” is a dangerous label 😄 (see #44)

@csarven
Copy link

csarven commented Jan 10, 2017

After a new git clone, on master branch, and make from within hdt-lib, I'm still getting (on Ubuntu 16.10):

 [C++] Compiling static/suffixtree/RMQ_succinct.cpp
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-1’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
  const DTsucc RMQ_succinct::HighestBitsSet[8] = {~0, ~1, ~3, ~7, ~15, ~31, ~63, ~127};
                                                                                     ^
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-2’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-4’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-8’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-16’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-32’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-64’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
static/suffixtree/RMQ_succinct.cpp:116:85: error: narrowing conversion of ‘-128’ from ‘int’ to ‘DTsucc {aka unsigned char}’ inside { } [-Wnarrowing]
Makefile:35: recipe for target 'static/suffixtree/RMQ_succinct.o' failed
make[3]: *** [static/suffixtree/RMQ_succinct.o] Error 1
Makefile:39: recipe for target 'all' failed
make[2]: *** [all] Error 2
Makefile:13: recipe for target 'libcompact' failed
make[1]: *** [libcompact] Error 2
make[1]: Leaving directory '/var/www/hdt-cpp/libcds-v1.0.12'
Makefile:57: recipe for target 'all' failed
make: *** [all] Error 2

@RubenVerborgh
Copy link
Member

And you're not, @wouterbeek?

@RubenVerborgh RubenVerborgh reopened this Jan 10, 2017
@csarven
Copy link

csarven commented Jan 10, 2017

Just to be sure.. is the make touching anything outside of the cloned location that should be wiped off before a new make?

@RubenVerborgh
Copy link
Member

Not the cloned location, but it is touching files outside of hdt-lib.

@wouterbeek
Copy link
Contributor Author

@csarven is right: removing the hdt-cpp directory, cloning a new copy, then running make brings up the same errors for me after all... Earlier I relied on make clean, but apparently this does not clean all files properly? (TWIUI running make clean and then make should not have dramatically different behavior from removing and re-cloning.)

As a quick fix you can make the two substitutions that I mention in my top post. That fixes compilation for me on the following three machines/configurations: Fedora 24 GCC 6.1.1, Ubuntu 16.04 GCC 5.4.0, Ubuntu 16.10 GCC 6.2.0.

BTW I also have to add -fPIC to FLAGS in order to use the HDT libraries from other C++ code. (This is not needed for running HDT as a standalone program I believe.)

@RubenVerborgh
Copy link
Member

Aha, I'm able to reproduce your bug: https://travis-ci.org/rdfhdt/hdt-cpp/jobs/190684926.

Will indeed apply the above fix.

@csarven
Copy link

csarven commented Jan 10, 2017

 [HDT] Compiling src/rdf/RDFParserSerd.cpp
In file included from src/rdf/RDFParserSerd.cpp:6:0:
src/rdf/RDFParserSerd.hpp:8:30: fatal error: serd-0/serd/serd.h: No such file or directory
 #include <serd-0/serd/serd.h>
                              ^
compilation terminated.
Makefile:100: recipe for target 'src/rdf/RDFParserSerd.o' failed
make[1]: *** [src/rdf/RDFParserSerd.o] Error 1
make[1]: Leaving directory '/var/www/hdt-cpp/hdt-lib'
Makefile:63: recipe for target 'all' failed
make: *** [all] Error 2

@RubenVerborgh
Copy link
Member

RubenVerborgh commented Jan 10, 2017

Ah, but SERD is a prerequisite.

  # Download and install SERD
  curl -s http://download.drobilla.net/serd-0.24.0.tar.bz2 | tar -xj
  pushd serd-* && ./waf configure && ./waf && sudo ./waf install && popd
  # Download and install Raptor
  curl -s http://download.librdf.org/source/raptor2-2.0.15.tar.gz | tar -xz
  pushd raptor2-* && ./configure && make -j2 && sudo make install && popd

@wouterbeek
Copy link
Contributor Author

The project README says that Serd is optional.

@RubenVerborgh
Copy link
Member

Yeah, I required it in bc7a258, as the other parser was horribly broken. Updated README in 1126396.

@wouterbeek
Copy link
Contributor Author

@RubenVerborgh Thanks for the info. Good choice to go with Serd!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants