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++/15528] endless loop with recursive template instantiation


------- Additional Comments From bangerth at dealii dot org  2004-05-19 13:52 -------
The code as Andrew gave it is invalid because it uses the default 
constructor A<T>() for the default value. This constructor does 
not exists, however. 
 
The following doesn't have this problem and still gets gcc 3.4 into 
an endless loop: 
---------------- 
template<class T> struct A 
{ 
    static const A<T> & foo(const A<T>& = foo()); 
}; 
 
int main () 
{ 
  A<int> a; 
  a.foo(); 
} 
--------------------- 
 
For reference, icc 7.1 says 
x.cc(3): error: recursive instantiation of default argument 
      static const A<T> & foo(const A<T>& = foo()); 
                                                ^ 
          detected during instantiation of "const A<T> &A<T>::foo(const A<T> 
&) [with T=int]" at line 9 
 
compilation aborted for x.cc (code 2) 
 
As far as I can tell, the code puts every gcc version since at least 
2.95 into a tailspin. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |2.95.3 3.3.1 3.0.4 3.4.0
                   |                            |3.5.0
            Summary|segmentation fault with     |endless loop with recursive
                   |invalid code                |template instantiation


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15528


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