https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62126
Bug ID: 62126 Summary: -Wshadow for typedef and template parm Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: humbug at deeptown dot org $ g++ -v -Wall -Wextra -Wshadow -Wpedantic gcc_shadow.cpp Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.8/lto-wrapper Target: i686-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.1-10ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-i386/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-i386 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-i386 --with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-targets=all --enable-multiarch --disable-werror --with-arch-32=i686 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu Thread model: posix gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9) COLLECT_GCC_OPTIONS='-v' '-Wall' '-Wextra' '-Wshadow' '-Wpedantic' '-shared-libgcc' '-mtune=generic' '-march=i686' /usr/lib/gcc/i686-linux-gnu/4.8/cc1plus -quiet -v -imultiarch i386-linux-gnu -D_GNU_SOURCE gcc_shadow.cpp -quiet -dumpbase gcc_shadow.cpp -mtune=generic -march=i686 -auxbase gcc_shadow -Wall -Wextra -Wshadow -Wpedantic -version -fstack-protector -Wformat -Wformat-security -o /tmp/ccWvf8WF.s GNU C++ (Ubuntu/Linaro 4.8.1-10ubuntu9) version 4.8.1 (i686-linux-gnu) compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.1-p2, MPC version 1.0.1 The following harmful code reports NO warnings: #include <iostream> class A { public: static void hello() { std::cerr << "A::hello()" << std::endl; } }; class B { public: static void hello() { std::cerr << "B::hello()" << std::endl; } }; template<typename type> class Base { public: typedef type type_t; static void hello() { typedef int type_t; // <<< shadowing type_t type_t x = type_t(); } }; template<typename type> class Derived_typedef : public Base<A> { public: typedef type type_t; // <<< shadowing Base<A>::type_t static void hello() { type_t::hello(); } }; template<typename type_t> class Derived_template_param : public Base<A> // <<< shadowing template parm type_t { public: static void hello() { type_t::hello(); } }; int main() { Derived_typedef<B>::hello(); Derived_template_param<B>::hello(); return 0; }