This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/23789] [3.4/4.0/4.1 Regression] compilation error when template parameters have certain complexity


------- 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 &#8216;X<6>&#8217;: 
x.cc:10:   instantiated from here 
x.cc:4: error: &#8216;(((int)true) + 7)&#8217; is not a valid template argument for type 
&#8216;int&#8217; because it is a non-constant expression 
x.cc: In function &#8216;void foo()&#8217;: 
x.cc:10: error: no match for &#8216;operator+&#8216; in &#8216;A + B&#8216; 
 
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]