------- Additional Comments From bangerth at dealii dot org 2005-09-09 14:06 ------- This is weird indeed. Here's the shortest I can come up with: ------------------- template <int W> struct X { template <int W2> X< (W+(W&&W) > 1 ? W+(W&&W) : 1)+1> operator + (const X<W2>&) const; }; template <int dummy> void foo() { X<6> A,B; A + B; } ----------------------------- The expression in the return type isn't fully folded, as Andrew noted: g/x> /home/bangerth/bin/gcc-4.1-pre/bin/c++ -c x.cc x.cc: In instantiation of ‘X<6>’: x.cc:10: instantiated from here x.cc:4: error: ‘(((int)true) + 7)’ is not a valid template argument for type ‘int’ because it is a non-constant expression x.cc: In function ‘void foo()’: x.cc:10: error: no match for ‘operator+‘ in ‘A + B‘ Weird enough, however, is that if I rename operator+ into a regular member function, then things work just fine. Somebody's gotta explain this to me... W.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23789