vgteam / vg

tools for working with genome variation graphs
https://biostars.org/tag/vg/
Other
1.11k stars 195 forks source link

Compilation Error: call of overloaded ‘abs(size_t)’ #673

Closed fbemm closed 7 years ago

fbemm commented 7 years ago

I am trying to compile the latest commit. Fails with:

g++ -c -o src/Variant.o src/Variant.cpp -Itabixpp/htslib -Iinclude -L. -Ltabixpp/htslib -Llib -lvcflib -lhts -lpthread -lz -lm -O3 -D_FILE_OFFSET_BITS=64 -std=c++0x && cp src/.h /ebio/abt6_projects9/abt6_software/bin/vg/deps/vcflib/include/ src/Variant.cpp: In member function ‘bool vcflib::Variant::canonicalize_sv(FastaReference&, std::vector<FastaReference*>, int)’: src/Variant.cpp:167:111: error: call of overloaded ‘abs(size_t)’ is ambiguous sv_len = abs((size_t) stol(this->info["END"][alt_pos]) - (size_t) (this->position)); ^ In file included from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/cstdlib:72:0, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/ext/string_conversions.h:41, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5249, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/string:52, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/stdexcept:39, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/array:38, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/tuple:39, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/bits/stl_map.h:63, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/map:61, from src/Variant.h:6, from src/Variant.cpp:1: /usr/include/stdlib.h:775:12: note: candidate: int abs(int) extern int abs (int x) THROW attribute ((const)) wur; ^ In file included from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/ext/string_conversions.h:41:0, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5249, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/string:52, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/stdexcept:39, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/array:38, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/tuple:39, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/bits/stl_map.h:63, from /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/map:61, from src/Variant.h:6, from src/Variant.cpp:1: /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/cstdlib:174:3: note: candidate: long long int std::abs(long long int) abs(long long x) { return builtin_llabs (x); } ^ /ebio/abt6_projects9/abt6_software/bin/gcc-5.4.0/include/c++/5.4.0/cstdlib:166:3: note: candidate: long int std::abs(long int) abs(long i) { return builtin_labs(__i); } ^ make[1]: [src/Variant.o] Error 1 make[1]: Leaving directory `/ebio/abt6_projects9/abt6_software/bin/vg/deps/vcflib' make: [lib/libvcflib.a] Error 2

Any idea?

edawson commented 7 years ago

I did this it looks like, but I haven't seen it break. I'm on gcc4.9 though, so maybe gcc5.4 has stricter rules about calling an overloaded function on size_t, which can be almost any numeric type.

I'll push a fix by just limiting that cast to int and make sure Erik gets it into master today. Thanks for letting me know about the bug.

fbemm commented 7 years ago

Thanks for looking into the issue. I could also test your fix before things are merged into the master.

edawson commented 7 years ago

Sure - there's a fix on the branch in this PR: https://github.com/vcflib/vcflib/pull/183

Jerven has also proposed a fix here: https://github.com/vcflib/vcflib/issues/177

fbemm commented 7 years ago

I applied the fix and it worked!