g++ -Wshadow emitting a warning from libstdc++

Martin Sebor sebor@roguewave.com
Sat Aug 19 17:25:00 GMT 2000


Hi,

the definition of ::abs() in <cmath> is causing a warning with g++
-Wshadow. The warning disappears with -fno-builtin but there doesn't
appear to be a way to test for this flag at compile time (i.e., there's
no macro that one could check to see whether abs should be defined or
not). It would be useful if like edg, g++ also #defined corresponding
macros for such flags (e.g., _GCC_NO_BUILTIN, _GCC_NO_HONOR_STD, etc.).
Just a suggestion...

Regards
Martin

$ cat test.cpp

#include <cmath.h>


$ g++ -Wshadow test.cpp
In file included from test.cpp:3:
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3/cmath:
In function `float abs(float)':
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3/cmath:40:
warning: shadowing built-in function `int abs(int)'


More information about the Gcc-bugs mailing list