This code ---------------------- template <typename T> struct length { static const int value = 3; }; template <typename T, int L = length<T>::value> struct S {}; template <typename T> S<T> bar (T); template <int dim> void foo () { bar (1); } ----------------------------- Used to compile with gcc 4.0.1pre (20050531), but it doesn't any more with today's snapshot of the 4.0.2 branch. It apparently doesn't recognize length<T>::value as an integer constant expression any more: > /home/bangerth/bin/gcc-4.0.2-pre/bin/c++ -c source/grid/grid_generator.cc source/grid/grid_generator.cc: In function ‘void foo()’: source/grid/grid_generator.cc:11: error: ‘length<int>::value’ is not a valid template argument for type ‘int’ because it is a non-constant expression source/grid/grid_generator.cc:11: error: no matching function for call to ‘bar(int)’ I don't really see how to work around this problem short of specifying the value of the second template argument by hand. This bug will (again) prevent 4.0.2 from being able to compile one of the proposed SPEC 2005 benchmarks (4.0.1 couldn't do this due to PR 21799). It would be nice if this could be fixed before 4.0.2 comes out. Thanks Wolfgang
-- Summary: [4.0.2 regression] Constant template argument not recognized as such Product: gcc Version: 4.0.2 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bangerth at dealii dot org CC: gcc-bugs at gcc dot gnu dot org,mmitchel at gcc dot gnu dot org,nathan at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23771