Instead of keeping PR 15554 open, I decided to open a new bug as it is caused by a different problem. template <int n> struct T1 { enum { N = 3 }; }; template <int n> struct T2 { enum { N = n, N1 = T1<N>::N }; };
Yes, this was already confirmed. It's a critical regression. W.
Working on a fix.
Subject: Bug 15877 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-06-10 14:26:23 Modified files: gcc/cp : ChangeLog parser.c pt.c typeck.c Added files: gcc/testsuite/g++.dg/conversion: const1.C reinterpret1.C gcc/testsuite/g++.dg/template: enum2.C error13.C Log message: PR c++/15227 * parser.c (cp_parser_direct_declarator): Robustify. PR c++/15877 * pt.c (tsubst_copy): Use decl_constant_value on enumeration constants in non-dependent contexts. PR c++/14211 PR c++/15076 * typeck.c (build_static_cast): Wrap casts in NON_LVALUE_EXPR when necessary. PR c++/14211 * g++.dg/conversion/const1.C: New test. PR c++/15076 * g++.dg/conversion/reinterpret1.C: New test. PR c++/15877 * g++.dg/template/enum2.C: New test. PR c++/15227 * g++.dg/template/error13.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4089&r2=1.4090 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.202&r2=1.203 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.860&r2=1.861 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.548&r2=1.549 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/const1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/reinterpret1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/enum2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error13.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 15877 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-06-10 14:26:50 Modified files: gcc/cp : ChangeLog parser.c pt.c typeck.c Added files: gcc/testsuite/g++.dg/conversion: const1.C reinterpret1.C gcc/testsuite/g++.dg/template: enum2.C error13.C Log message: PR c++/15227 * parser.c (cp_parser_direct_declarator): Robustify. PR c++/15877 * pt.c (tsubst_copy): Use decl_constant_value on enumeration constants in non-dependent contexts. PR c++/14211 PR c++/15076 * typeck.c (build_static_cast): Wrap casts in NON_LVALUE_EXPR when necessary. PR c++/14211 * g++.dg/conversion/const1.C: New test. PR c++/15076 * g++.dg/conversion/reinterpret1.C: New test. PR c++/15877 * g++.dg/template/enum2.C: New test. PR c++/15227 * g++.dg/template/error13.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.119&r2=1.3892.2.120 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.32&r2=1.157.2.33 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.29&r2=1.816.2.30 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.519.2.19&r2=1.519.2.20 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/const1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/reinterpret1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/enum2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error13.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.4.1.
the following code is fairly similar to this bug, but it is rejected by g++ 4.0.0: x.cc:10: error: '(Arg1 + 1)' is not a valid template argument for type 'int' because it is a non-constant expression x.cc:10: error: 'value' is not a member of '<declaration error>' is it a new bug? (accepted by comeau c++) (NoBug1 and NoBug2 are workarounds) """ template <int x> struct Id { enum { value = x }; }; template <int Arg1> struct Bug { enum Spam { enum1 = Arg1, enum2 = enum1+1, enum3 = Id<enum2>::value }; }; template <int Arg1> struct NoBug1 { enum { enum1 = Arg1, enum2 = Arg1+1, enum3 = Id<enum2>::value }; }; template <int Arg1> struct NoBug2 { enum { enum1 = Arg1, enum2 = enum1+1 }; enum { enum3 = Id<enum2>::value }; }; """
Please open a new bugreport for this bug.