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: unassig...@gcc.gnu.org ReportedBy: ja...@gcc.gnu.org CC: ja...@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.