This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/6778: fails to compile template
- From: sfking00 at hotmail dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 23 May 2002 06:56:55 -0000
- Subject: c++/6778: fails to compile template
- Reply-to: sfking00 at hotmail dot com
>Number: 6778
>Category: c++
>Synopsis: fails to compile template
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Thu May 23 00:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: sfking00@hotmail.com
>Release: Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs Configured with: ../../../../export/src/gcc-3.1/configure -enable-shared -enable-threads Thread model: posix gcc version 3.1
>Organization:
>Environment:
Red Hat 7.1 on a p2-400 w/256 megs ram, linux kernel 2.4.18
>Description:
c++ -g -O0 -fmessage-length=0 -Wall -c test.cc
test.cc:29: internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
make: *** [test.o] Error 1
>How-To-Repeat:
namespace
{
template < unsigned N, typename T = double > class X {};
template < unsigned N, typename T = double > class Y {};
template < unsigned N, typename T >
Y < N - 1, T >
operator * (X < N, T > const &, Y < N, T > const &) throw ()
{
return Y < N - 1, T > ();
}
#if 1
template < unsigned N, typename T >
Y < N + 1, T >
operator * (X < N + 1, T > const &, Y < N, T > const &) throw ()
{
return Y < N + 1, T > ();
}
#else
template < unsigned N, typename T >
Y < N, T >
operator * (X < N, T > const &, Y < N - 1, T > const &) throw ()
{
return Y < N, T > ();
}
#endif
template Y < 1, double > operator * (X < 2, double > const &, Y < 2, double > const &) throw ();
template Y < 2, double > operator * (X < 2, double > const &, Y < 1, double > const &) throw ();
}
int
main ()
{
try
{
}
catch (...)
{
}
return 0;
}
>Fix:
the code inside the #if 1 will not compile with 3.1 but will with 3.0.4 and earlier, but change the #if 1 to #if 0 and it will compile with 3.1 but not with earlier versions of gcc.
(either form compiles with the Comeau online compiler)
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="test.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cc"
bmFtZXNwYWNlCnsKCXRlbXBsYXRlIDwgdW5zaWduZWQgTiwgdHlwZW5hbWUgVCA9IGRvdWJsZSA+
IGNsYXNzIFgge307Cgl0ZW1wbGF0ZSA8IHVuc2lnbmVkIE4sIHR5cGVuYW1lIFQgPSBkb3VibGUg
PiBjbGFzcyBZIHt9OwoKCXRlbXBsYXRlIDwgdW5zaWduZWQgTiwgdHlwZW5hbWUgVCA+CglZIDwg
TiAtIDEsIFQgPgoJb3BlcmF0b3IgKiAoWCA8IE4sIFQgPiBjb25zdCAmLCBZIDwgTiwgVCA+IGNv
bnN0ICYpIHRocm93ICgpCgl7CgkJcmV0dXJuIFkgPCBOIC0gMSwgVCA+ICgpOwoJfQojaWYgMQoJ
dGVtcGxhdGUgPCB1bnNpZ25lZCBOLCB0eXBlbmFtZSBUID4KCVkgPCBOICsgMSwgVCA+CglvcGVy
YXRvciAqIChYIDwgTiArIDEsIFQgPiBjb25zdCAmLCBZIDwgTiwgVCA+IGNvbnN0ICYpIHRocm93
ICgpCgl7CgkJcmV0dXJuIFkgPCBOICsgMSwgVCA+ICgpOwoJfQojZWxzZQoJdGVtcGxhdGUgPCB1
bnNpZ25lZCBOLCB0eXBlbmFtZSBUID4KCVkgPCBOLCBUID4KCW9wZXJhdG9yICogKFggPCBOLCBU
ID4gY29uc3QgJiwgWSA8IE4gLSAxLCBUID4gY29uc3QgJikgdGhyb3cgKCkKCXsKCQlyZXR1cm4g
WSA8IE4sIFQgPiAoKTsKCX0KI2VuZGlmCgoKCXRlbXBsYXRlIFkgPCAxLCBkb3VibGUgPiBvcGVy
YXRvciAqIChYIDwgMiwgZG91YmxlID4gY29uc3QgJiwgWSA8IDIsIGRvdWJsZSA+IGNvbnN0ICYp
IHRocm93ICgpOwoJdGVtcGxhdGUgWSA8IDIsIGRvdWJsZSA+IG9wZXJhdG9yICogKFggPCAyLCBk
b3VibGUgPiBjb25zdCAmLCBZIDwgMSwgZG91YmxlID4gY29uc3QgJikgdGhyb3cgKCk7Cn0KCmlu
dAptYWluICgpCnsKCXRyeQoJewoJfQoJY2F0Y2ggKC4uLikKCXsKCX0KCXJldHVybiAwOwp9Cg==