This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/23789] [3.4/4.0/4.1 Regression] compilation error when template parameters have certain complexity
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Sep 2005 14:06:15 -0000
- Subject: [Bug c++/23789] [3.4/4.0/4.1 Regression] compilation error when template parameters have certain complexity
- References: <20050909022508.23789.andres_takach@mentor.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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