public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/5050: template instantiation depth exceeds...
@ 2003-01-11 21:16 Nathanael Nerode
  0 siblings, 0 replies; only message in thread
From: Nathanael Nerode @ 2003-01-11 21:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/5050; it has been noted by GNATS.

>From neroden@twcny.rr.com  Mon Jan 13 01:00:41 2003
From: Nathanael Nerode <neroden@twcny.rr.com>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, georg.wild@gmx.de,
   gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/5050: template instantiation depth exceeds...
Date: Sat, 11 Jan 2003 16:07:43 -0500

 The following testcase fails when compiled with -ftemplate-depth-1 -O2 or 
 -ftemplate-depth-1 -O1, but not -ftemplate-depth-1 -O0.  (It's always OK with 
 template depth higher than 1).
 
 This is the error message:
 ----
 test.cxx:5: error: template instantiation depth exceeds maximum of 1 (use
    -ftemplate-depth-NN to increase the maximum) instantiating `ostream&
    ostream::foo(const T&) [with T = int]'
 test.cxx:5:   instantiated from `ostream& ostream::foo(const T&) [with T = 
 int]'test.cxx:12:   instantiated from here
 ----
 
 The problem appears to be that the compiler doesn't realize that it's already 
 instantiated `ostream& ostream::foo(const T&) [with T = int]'.  It doesn't 
 have to instantiate it repeatedly, does it now?  At any rate, behaving 
 differently with optimization is a no-no.
 
 This is the testcase:
 ----
 struct ostream
 {
   template<class T> ostream& foo( const T & )
   {
     return *this;
   }
 };
 
 void foo()
 {
   ostream os;
   (os.foo(1)).foo(2);
 }
 ----


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-01-11 21:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-11 21:16 c++/5050: template instantiation depth exceeds Nathanael Nerode

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).