public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/6778: fails to compile template
@ 2002-05-23  6:55 lerdsuwa
  0 siblings, 0 replies; 2+ messages in thread
From: lerdsuwa @ 2002-05-23  6:55 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, sfking00

Synopsis: fails to compile template

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Thu May 23 06:55:44 2002
State-Changed-Why:
    Fixed in the main trunk.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6778


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/6778: fails to compile template
@ 2002-05-23  0:06 sfking00
  0 siblings, 0 replies; 2+ messages in thread
From: sfking00 @ 2002-05-23  0:06 UTC (permalink / raw)
  To: gcc-gnats


>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==


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-05-23 13:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-23  6:55 c++/6778: fails to compile template lerdsuwa
  -- strict thread matches above, loose matches on Subject: below --
2002-05-23  0:06 sfking00

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).