------- Comment #2 from bangerth at dealii dot org 2008-02-10 01:13 ------- Confirmed. This was introduced in 3.4.x, and worked before. As Andrew already noted, this has been fixed in mainline.
The problem can be more succinctly shown by the following testcase: -------------------- template <typename T> struct S {}; template <typename R> struct ref; template <> struct ref<double> { typedef double result; }; template <typename T> void foo(typename ref<T>::result, S<T>*); template <> void foo(S<double>, S<double>*); template <> void foo(double alpha, S<double>* x) { alpha; x; } ----------------------- g/x> c++-4.2.1 -S x.cc x.cc: In function 'void foo(typename ref<R>::result, S<T>*) [with T = double]': x.cc:10: error: 'alpha' was not declared in this scope x.cc:10: error: 'x' was not declared in this scope What is happening is that we are looking up the parameters from the wrong declaration. The function in question on line 10 of course has them declared and named, but we are looking at the specialization in line 7: if the parameters are named there, then the code compiles. However, as shown in the original testcase, the parameters then have the wrong type. It shouldn't be too hard to construct a case where this produces wrong code. Can someone determine whether this is still wrong with the released 4.2.3? I consider this a particularly heinous bug since it's almost impossible to see in a real code where the error is coming from (if we get one) or why the produced code is wrong. W. -- bangerth at dealii dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bangerth at dealii dot org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Known to fail| |4.2.1 4.1.2 4.0.4 3.4.6 Known to work|4.3.0 |4.3.0 3.3.6 Last reconfirmed|0000-00-00 00:00:00 |2008-02-10 01:13:11 date| | Summary|weird error in template |[4.1/4.2 regression] weird |function specialization |error in template function | |specialization http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35146