This is the mail archive of the
mailing list for the GCC project.
Re: Strange C++ function pointer test
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Dominik Vogt <vogt at linux dot vnet dot ibm dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Thu, 31 Dec 2015 13:17:25 +0000
- Subject: Re: Strange C++ function pointer test
- Authentication-results: sourceware.org; auth=none
- References: <20151231094918 dot GA12885 at linux dot vnet dot ibm dot com> <alpine dot DEB dot 2 dot 20 dot 1512311055290 dot 17945 at laptop-mg dot saclay dot inria dot fr> <CAH6eHdTASETHDhGYdC60iOw1PgmtUOhwVT_iJ4Fi4ZCYCzomyg at mail dot gmail dot com> <20151231113458 dot GA19211 at linux dot vnet dot ibm dot com> <alpine dot DEB dot 2 dot 20 dot 1512311240240 dot 23439 at laptop-mg dot saclay dot inria dot fr> <20151231115440 dot GA32205 at linux dot vnet dot ibm dot com> <CAH6eHdSVmicNOqYYX2AweXE=fRYTAX73sAYDGSMq06ZgzAGT1g at mail dot gmail dot com> <20151231130923 dot GA9057 at linux dot vnet dot ibm dot com>
On 31 December 2015 at 13:09, Dominik Vogt <email@example.com> wrote:
> On Thu, Dec 31, 2015 at 12:42:56PM +0000, Jonathan Wakely wrote:
>> On 31 December 2015 at 11:54, Dominik Vogt wrote:
>> > Is there a requirement for a certain minimum Glibc version for
>> > this to work?
>> It doesn't work with any glibc, because it doesn't declare the C++ overloads.
> All right, so, the situation is:
> * The test includes just stdlib.h and math.h.
> * The test expects the float variant of abs to be available.
> * It tests the C++ compiler on C code, so it *does not* use any
> C++ specific code (namespace or C++ headers).
That sentence is meaningless. If you use a C++ compiler then you're
compiling C++ code.
> * The C++-11 standard does *not* require that any overloaded
> variants of abs() are available when inclding math.h, right?
Wrong. As specified in [c.math], <cmath> declares these in namespace std:
long double abs(long double);
and <math.h> declares the same overloads in the global namespace.
> The assumption that the test should compile without error is
No, the test is valid.
> The test seems to assume that including math.h with the
> C++ compiler is the same as including cmath.
No it doesn't. If the test included <cmath> then it would have to use
std::abs. Because it includes <math.h> it uses ::abs.
>> Libstdc++ has an include/c_compatibility/math.h header that would
>> include <cmath> (which declares the C++ overloads) and then pull them
>> into the global namespace, but that isn't used on GNU/Linux, and would
>> create other problems.
>> This is already in Bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60401
> Yet this bug report wants stdlib.h (or math.h) included from C++
> to add the non-int signatures to the abs() function?