This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15877] [3.4/4.0 Regression] valid code using templates and anonymous enums is rejected
- From: "llib at computer dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 May 2005 05:46:08 -0000
- Subject: [Bug c++/15877] [3.4/4.0 Regression] valid code using templates and anonymous enums is rejected
- References: <20040608181441.15877.pinskia@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From llib at computer dot org 2005-05-02 05:46 -------
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
};
};
"""
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15877