This is the mail archive of the
mailing list for the GCC project.
Re: Strange C++ function pointer test
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Dominik Vogt <vogt at linux dot vnet dot ibm dot com>, Andreas Krebbel <krebbel at linux dot vnet dot ibm dot com>
- Date: Thu, 31 Dec 2015 12:37:41 +0100 (CET)
- 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>
- Reply-to: gcc at gcc dot gnu dot org
On Thu, 31 Dec 2015, Jonathan Wakely wrote:
There are other overloads of 'abs' declared in math.h / cmath (only in
namespace std in the second case, and there are bugs (or standard issues)
about having them in the global namespace for the first one).
That's not quite accurate, C++11 was altered slightly to reflect reality.
<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.
$ cat a.cc
$ g++-snapshot a.cc -c -Wall -W
a.cc: In function 'int main()':
a.cc:3:10: error: 'abs' was not declared in this scope
That's what I called "bug" in my message (there are a few bugzilla PRs for
this). It would probably work on Solaris.
And I seem to remember there are at least 2 open LWG issues on the topic,
one saying that the C++11 change didn't go far enough to match reality,
since it still documents C headers differently from the C standard, and
one saying that all overloads of abs should be declared as soon as one is
(yes, they contradict each other).