[Bug c++/55127] [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter

2012-10-29 Thread gccbugs at qo dot cx


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55127



--- Comment #1 from Philipp A. Hartmann  2012-10-29 
20:17:32 UTC ---

Created attachment 28565

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28565

minimal test-case (and workaround)



Without WORKAROUND being defined, GCC 4.8 fails with the mentioned error

message.  Otherwise with WORKAROUD defined all tested versions accept the code.


[Bug c++/55127] New: [4.8 regression] Incorrect "dependent scope" error with partial specialisation of non-type parameter

2012-10-29 Thread gccbugs at qo dot cx


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: unassig...@gcc.gnu.org

ReportedBy: gccb...@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::type' because 'wrapper' is a dependent scope

   wrapper::type x;

   ^

typename-bug.cpp:29:29: error: expected ';' before 'x'

   wrapper::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::type' is

parsed as a non-type, but instantiation yields a type

   wrapper::type x;

   ^

typename-bug.cpp:29:3: note: say 'typename wrapper::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