This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15528] endless loop with recursive template instantiation
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 May 2004 13:52:27 -0000
- Subject: [Bug c++/15528] endless loop with recursive template instantiation
- References: <20040518224904.15528.igodard@pacbell.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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