[Bug c++/48936] New: [4.3/4.4/4.5/4.6 Regression] sizeof template parm not considered constant expression
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 9 15:58:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48936
Summary: [4.3/4.4/4.5/4.6 Regression] sizeof template parm not
considered constant expression
Product: gcc
Version: 4.4.7
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jakub@gcc.gnu.org
CC: jason@gcc.gnu.org
template <bool C> int foo (void);
template <class T> struct S
{
static const unsigned int a = sizeof (T);
enum { c = sizeof (foo <(a == 0)> ()) };
};
S<int> x;
compiles fine with 3.3, 3.4, 4.6 and trunk, fails in 4.0 - 4.5 with:
x.C: In instantiation of ‘S<int>’:
x.C:7: instantiated from here
x.C:5: error: ‘(((unsigned int)S<int>::a) == 0u)’ is not a valid template
argument for type ‘bool’ because it is a non-constant expression
x.C:5: error: no matching function for call to ‘foo()’
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163895
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166164
is what fixed it for 4.6/4.7, but Jason has a smaller fix for the older release
branches.
More information about the Gcc-bugs
mailing list