Consider the following example: #include <cmath> // Okay if we do this: //using std::floor; double f(double d) { // If we do this, however, GCC says: "shadow.C:7: warning: // shadowing built-in function `double std::floor(double)'" using std::floor; return floor(d); }
As indicated in the comments, the example compiles without warnings when using -Wshadow IFF 'using std::floor' is at file scope. However, if the using declaration is moved inside of a function, GCC complains about shadowing a built-in. ------- [EMAIL PROTECTED]:~/playpen$ g++-3.4 -v Reading specs from /usr/lib/gcc/i486-linux/3.4.4/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --disable-werror i486-linux Thread model: posix gcc version 3.4.4 20050314 (prerelease) (Debian 3.4.3-13) -- Summary: -Wshadow gets confused by built-ins Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: cnewbold at mathworks dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24368