public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gccbugs at qo dot cx" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter Date: Mon, 29 Oct 2012 20:15:00 -0000 [thread overview] Message-ID: <bug-55127-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127 Bug #: 55127 Summary: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: gccbugs@qo.cx The current GCC snapshot in Debian unstable seems to reject valid code (mininal test case attached). In a template function context, accessing a nested type of a template instantiation of an unrelated(!) template class may be flagged as requiring a 'typename' for being a dependent scope. AFAICS, it only happens in case of the instantiated template being partially specialised for a non-type template parameter, like bool here: struct some_class { static const bool is_valid_type = true; }; template< typename Type , bool Valid = Type::is_valid_type > struct wrapper; template< typename Type > struct wrapper< Type, true > { ... }; template< typename T > int fun() { wrapper< some_class >::type x; // fails w/ 4.8.0 } $ g++-snapshot -c -o typename-bug.o typename-bug.cpp typename-bug.cpp: In function 'void fun()': typename-bug.cpp:29:3: error: need 'typename' before 'wrapper<some_class>::type' because 'wrapper<some_class>' is a dependent scope wrapper<some_class>::type x; ^ typename-bug.cpp:29:29: error: expected ';' before 'x' wrapper<some_class>::type x; ^ typename-bug.cpp: In instantiation of 'void fun() [with T = int]': typename-bug.cpp:34:12: required from here typename-bug.cpp:29:3: error: dependent-name 'wrapper<some_class>::type' is parsed as a non-type, but instantiation yields a type wrapper<some_class>::type x; ^ typename-bug.cpp:29:3: note: say 'typename wrapper<some_class>::type' if a type is meant A possible workaround is to partially specialise via a type parameter (as shown in the attached file with WORKAROUND being defined). The failing GCC version reports: Using built-in specs. COLLECT_GCC=g++-snapshot COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/i486-linux-gnu/4.8.0/lto-wrapper Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 20121008-1' --with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs --enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++ --prefix=/usr/lib/gcc-snapshot --enable-shared --enable-linker-build-id --with-system-zlib --disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-snap/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-snap --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-snap --with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-targets=all --with-arch-32=i586 --with-tune=generic --disable-werror --enable-checking=yes --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.8.0 20121008 (experimental) [trunk revision 192192] (Debian 20121008-1) Code is accepted by all "other" GCC variants in Debian testing/unstable: Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.7-3' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-targets=all --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.4.7 (Debian 4.4.7-3) Using built-in specs. COLLECT_GCC=g++-4.6 COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.6/lto-wrapper Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-12' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.6.3 (Debian 4.6.3-12) Using built-in specs. COLLECT_GCC=g++-4.7 COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.7/lto-wrapper Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-4' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.7.2 (Debian 4.7.2-4)
next reply other threads:[~2012-10-29 20:15 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-10-29 20:15 gccbugs at qo dot cx [this message] 2012-10-29 20:18 ` [Bug c++/55127] " gccbugs at qo dot cx 2012-11-25 15:55 ` [Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialization " rguenth at gcc dot gnu.org 2012-12-06 15:33 ` paolo.carlini at oracle dot com 2012-12-07 10:18 ` paolo.carlini at oracle dot com 2012-12-07 13:27 ` rguenth at gcc dot gnu.org 2012-12-07 13:28 ` hjl.tools at gmail dot com 2012-12-07 14:30 ` paolo.carlini at oracle dot com 2012-12-07 19:30 ` jason at gcc dot gnu.org 2012-12-08 3:32 ` jason at gcc dot gnu.org 2012-12-08 3:33 ` jason at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-55127-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).