g++ bug2.cc -o bug2 -Wall bug2.cc: In member function `void Test<Rank>::dat_embrace(Test<LowRank>&)': bug2.cc:32: internal error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. in method dat_embrace, the template-rank-parameters are checked by a compile-time assert. It works well for Rank, but fails for LowRank Release: gcc version 3.2 20020818 (prerelease) Environment: @PC169/.../testThreads$ gcc -v Reading specs from /bin/../lib/gcc-lib/i686-pc-cygwin/3.2/specs Configured with: /netrel/src/gcc-3.2-1/configure --enable-languages=c,c++,f77,ja va --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --with out-included-gettext --enable-interpreter --disable-sjlj-exceptions --disable-ve rsion-specific-runtime-libs --enable-shared --build=i686-pc-linux --host=i686-pc -cygwin --target=i686-pc-cygwin --enable-haifa --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --includedir=/nonexistent/include --libexecd ir=/usr/sbin Thread model: posix gcc version 3.2 20020818 (prerelease)
Fix: Prove template parameter LowRank at runtime rather than at compile-time
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed.
From: Volker Reichelt <reichelt@igpm.rwth-aachen.de> To: schnoerr@mailzone.com, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: c++/8164: internal error: segmentation fault Date: Tue, 5 Nov 2002 19:05:27 +0100 Hi, the problem can be reduced to the following code snippet (which looks legal to me): -------------------------------snip here------------------------- template <bool> struct A {}; template <bool> struct B { void foo() { const int i=0; typedef A< i<=1 > C; typedef A< i<=2 > C; } }; -------------------------------snip here------------------------- gcc 2.95.x rejects the code with an error message. gcc 3.0.x, the 3.2 branch and mainline produce an ICE. Greetings, Volker http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8164
From: Volker Reichelt <reichelt@igpm.rwth-aachen.de> To: schnoerr@mailzone.com, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org Cc: Subject: Re: c++/8164: ICE when using different const expressions as template parameter Date: Wed, 15 Jan 2003 14:53:32 +0100 Just for the record, the ICE is gone on mainline, but we still have an error message which leaves us with a rejects-legal bug: PR8164.cc: In member function `void B<<anonymous> >::foo()': PR8164.cc:14: error: conflicting types for `typedef struct A<(i <= 2)> C' PR8164.cc:13: error: previous declaration as `typedef struct A<(i <= 1)> C' Regards, Volker http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8164
I don't know whether the code should be accepted, but just for the record: isn't it the case that the condition i<=2 is somehow mangled into the name of the class, i.e. not only the truth value but the expression? If this is the case, then the two types may be the same but will have different names, which would make things a little awkward. Just a very uninformed opinion, W.
Subject: Bug 8164 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: mmitchel@gcc.gnu.org 2003-07-11 08:46:57 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: nontype2.C Log message: PR c++/8164 * decl.c (duplicate_decls): Avoid mangling names unnecessarily. PR c++/8164 * g++.dg/template/nontype2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.179&r2=1.3076.2.180 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.54&r2=1.965.2.55 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.226&r2=1.2261.2.227 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
Subject: Bug 8164 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-07-11 08:53:59 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: nontype2.C Log message: PR c++/8164 * decl.c (duplicate_decls): Avoid mangling names unnecessarily. PR c++/8164 * g++.dg/template/nontype2.C: New test. PR c++/10558 * g++.dg/parse/template8.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2866&r2=1.2867 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nontype2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
Fixed in GCC 3.3.1, GCC 3.4.