This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29518] [4.0/4.1/4.2/4.3 Regression] rejects valid template argument, enums vs templates
- From: "news at derived-software dot ltd dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Nov 2006 11:04:46 -0000
- Subject: [Bug c++/29518] [4.0/4.1/4.2/4.3 Regression] rejects valid template argument, enums vs templates
- References: <bug-29518-5078@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #12 from news at derived-software dot ltd dot uk 2006-11-12 11:04 -------
>From Aleksey Gurtovoy (co-author Boost.MPL):
[wrt to this bug]
Actually, no, enums in the bug's subject and reduced test case are a
red herring. For example, this still fails for me on 4.1.1:
template< int C > int assertion_failed(int);
template< class > struct N
{
static int const value = 1;
static int const t = sizeof( assertion_failed<value>(0) );
};
int main()
{
N<int> n;
return n.t;
}
As a matter of fact, my current workaround for this issue involves
_introducing_ an auxiliary enum for the values that are used in
function templates' non-type arguments, e.g.:
template< int C > int assertion_failed(int);
template< class > struct N
{
static int const value = 1;
enum { gcc_workaround = value };
static int const t = sizeof( assertion_failed<gcc_workaround>(0) ); // it
compiles, yay!
};
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29518