with the following simplified test program (tabs.cc): ==================>8=============== #include <stdint.h> #include <stdlib.h> int64_t tabs(int64_t foo) { return abs(foo); } =================>8================ building with g++ -m32 -c tabs.cc gives the following error: >tabs.cc: In function ‘int64_t tabs(int64_t)’: >tabs.cc:6:16: error: call of overloaded ‘abs(int64_t&)’ is ambiguous > return abs(foo); > ^ >tabs.cc:6:16: note: candidates are: >In file included from /usr/include/stdlib.h:37:0, > from tabs.cc:2: >/usr/include/iso/stdlib_iso.h:165:16: note: long int std::abs(long int) > inline long abs(long _l) { return labs(_l); } > ^ >/usr/include/iso/stdlib_iso.h:119:12: note: int std::abs(int) > extern int abs(int); > ^ there is no error specifying -m64. Also, copying tabs.cc to tabs.c and building with gcc gives no error either ('gcc -m32 -c tabs.c' or to be pedantic with -std=c99 added). I should mention that this seems to work okay with gcc4.4.4, but reproducible with the compilers accessible, namely gcc47..gcc49. The test program seems to work fine on NetBSD and FreeBSD. This platform is SunOS 5.11 (illumos).
I should mention that rendering the test program pure c++ by replacing the first two lines with: >#include <cstdlib> >#include <cmath> allows the snippet build with both -m32 and -m64. It should be able to build as is, though.
long long (or int64_t) is not part of C++03, so solaris headers don't provide the overload. We complete the set of overloads in c* headers, but there is a well known bug that we don't provide wrappers for the *.h headers. It would be interesting to see how Oracle is updating the solaris headers for C++11.
Apparently with gcc 4.8.2 on Or*acle Solaris 11.2 the error manifests itself as well. Perhaps there is something [in the works] for s12?
I would expect that this is fixed (or at least the behavior changed) in recent versions of gcc, that ship a C++ stdlib.h wrapper. Can someone confirm?
Created attachment 39510 [details] tabs.ii No, I still see the issue with both v5 and 4.9.4 attached is tabs.ii using -save-temps
Sorry, by recent I meant at least 6.1, I should have been more specific.
Yes, this should be fixed in GCC 6, and if it isn't we now have the tools to fix it.
Fixed so closing.