public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49118] New: Endless operator-> chain causes infinite loop
@ 2011-05-23  2:56 potswa at mac dot com
  2011-05-23  8:13 ` [Bug c++/49118] " paolo.carlini at oracle dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: potswa at mac dot com @ 2011-05-23  2:56 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Endless operator-> chain causes infinite loop
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: potswa@mac.com


When the "drill-down" behavior is used to chain operator-> calls, a cycle in
the chain causes an immediate error message, but an endless acyclic chain
causes the compiler to hang, very slowly consuming memory.

Minimal case:

template< int n >
struct a { 
    a< n+1 > operator->() { return a< n+1 >(); }
};

int main() {
    a<0>()->x;
}

Suggested fix: If operator-> returns a template specialization, consider its
instantiation to be nested. This existing error message and limit-mechanism
would be appropriate:

error: template instantiation depth exceeds maximum of 500 (use
-ftemplate-depth-NN to increase the maximum) instantiating ‘struct a<500>’


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

end of thread, other threads:[~2013-02-25 22:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23  2:56 [Bug c++/49118] New: Endless operator-> chain causes infinite loop potswa at mac dot com
2011-05-23  8:13 ` [Bug c++/49118] " paolo.carlini at oracle dot com
2011-05-23  9:26 ` redi at gcc dot gnu.org
2011-05-23 11:24 ` rguenth at gcc dot gnu.org
2011-05-26  3:43 ` potswa at mac dot com
2011-05-26  5:44 ` potswa at mac dot com
2011-05-26  9:53 ` paolo.carlini at oracle dot com
2011-05-26 11:06 ` potswa at mac dot com
2011-06-10  5:18 ` jason at gcc dot gnu.org
2011-06-10  5:25 ` potswa at mac dot com
2011-07-01  0:56 ` jason at gcc dot gnu.org
2013-02-25 22:45 ` jakub at gcc dot gnu.org

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