On 31 December 2015 at 11:34, Dominik Vogt wrote: > On Thu, Dec 31, 2015 at 10:11:55AM +0000, Jonathan Wakely wrote: >> <cmath> is required to declare std::abs and it's unspecified whether >> it also declares it as ::abs. >> >> <math.h> is required to declare ::abs and it's unspecified whether it >> also declares it as std::abs. > > (*abs should be in <cstdlib> or <stdlib.h>).
For the integer overloads, yes, but in C++ the floating point overloads are in <cmath> and <math.h>. I did double-check the standard before posting, even though I know what I'm talking about quite well :-) Again, please see [c.math]. > I see. abs and ::abs are the same in this case, and std::abs > refers to the "double" variant, so that does not compile either. No, it refers to an overload set, which includes the float overload. > The minimal failing program is > > -- abs.C -- > #include <stdlib.h> > static float (*p1_)(float) = abs; > -- abs.C -- > > G++-6.0.0, Glibc-2.20 on S390x, compiled with > > $ g++ -std=c++11 abs.C > > The test program from the xvs suite includes stdlib.h and math.h, > but not cstdlib, cmath (or ctgmath). It's not clear to me which > headers g++ includes automatically, but this seems to be correct > behaviour, or is it not? Does it depend on the Glibc version? G++ doesn't include any headers automatically, but again, you need <cmath> or <math.h> for the floating point overloads.