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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  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 ` paolo.carlini at oracle dot com
  2011-05-23  9:26 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-23  8:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-23 07:44:01 UTC ---
For the record, ICC (EDG that is) misbehaves the same way, at least the
versions to which I have access. Maybe clang does something different?


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  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
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-23  9:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-23 08:22:00 UTC ---
nope, same behaviour for clang 2.8


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  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
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-23 11:24 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.05.23 10:58:00
     Ever Confirmed|0                           |1

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-23 10:58:00 UTC ---
Confirmed at least.


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  2011-05-23  2:56 [Bug c++/49118] New: Endless operator-> chain causes infinite loop potswa at mac dot com
                   ` (2 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: potswa at mac dot com @ 2011-05-26  3:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from David Krauss <potswa at mac dot com> 2011-05-26 03:37:44 UTC ---
Created attachment 24359
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24359
Patch fixes behavior but error message repeats twice.

I implemented the suggested fix, but the resulting error message repeats the
part about "template instantiation depth exceeds maximum" twice. The template
backtrace appears after the error, not before as with a usual nesting problem.
Is there something I'm obviously doing wrong here?

Here are the most relevant lines from the attached patch.

/* For diagnostic purposes, pretend that the chain is nested. */
if (CLASS_TYPE_P (chain_type) && CLASSTYPE_TEMPLATE_INFO (chain_type))
  push_tinst_level (chain_type);


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  2011-05-23  2:56 [Bug c++/49118] New: Endless operator-> chain causes infinite loop potswa at mac dot com
                   ` (3 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: potswa at mac dot com @ 2011-05-26  5:44 UTC (permalink / raw)
  To: gcc-bugs

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

David Krauss <potswa at mac dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24359|0                           |1
        is obsolete|                            |

--- Comment #5 from David Krauss <potswa at mac dot com> 2011-05-26 03:43:41 UTC ---
Created attachment 24360
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24360
replace crufty previous patch

See this patch instead. Previous unintentionally captured unrelated
development.


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  2011-05-23  2:56 [Bug c++/49118] New: Endless operator-> chain causes infinite loop potswa at mac dot com
                   ` (4 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-26  9:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-26 09:41:10 UTC ---
Maybe Jason can give you some tips, better sending the patch to the mailing
list for that, though, Bugzilla isn't meant for patches. CC Jason.


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  2011-05-23  2:56 [Bug c++/49118] New: Endless operator-> chain causes infinite loop potswa at mac dot com
                   ` (5 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: potswa at mac dot com @ 2011-05-26 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from David Krauss <potswa at mac dot com> 2011-05-26 11:05:12 UTC ---
Yes, I'll likely do that in a few days… just wanted to put the code in "safe
holding," just in case.


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  2011-05-23  2:56 [Bug c++/49118] New: Endless operator-> chain causes infinite loop potswa at mac dot com
                   ` (6 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-10  5:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> 2011-06-10 05:18:40 UTC ---
Author: jason
Date: Fri Jun 10 05:18:36 2011
New Revision: 174889

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174889
Log:
    PR c++/49118
    * typeck2.c (build_x_arrow): Push fake template context
    to produce diagnostic on acyclic endless operator-> drill-down.
    * call.c (build_new_op): Change Boolean overload status
    value to a pointer to the overload function.
    * cp-tree.h: Likewise.
    * typeck.c: Likewise.
    * parser.c: Likewise.
    * decl2.c: Likewise.
    * pt.c: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/template/arrow1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  2011-05-23  2:56 [Bug c++/49118] New: Endless operator-> chain causes infinite loop potswa at mac dot com
                   ` (7 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: potswa at mac dot com @ 2011-06-10  5:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from David Krauss <potswa at mac dot com> 2011-06-10 05:25:08 UTC ---
Thanks!

On Jun 9, 2011, at 10:18 PM, jason at gcc dot gnu.org wrote:

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


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  2011-05-23  2:56 [Bug c++/49118] New: Endless operator-> chain causes infinite loop potswa at mac dot com
                   ` (8 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-01  0:56 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> 2011-07-01 00:55:36 UTC ---
Fixed for 4.7.


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

* [Bug c++/49118] Endless operator-> chain causes infinite loop
  2011-05-23  2:56 [Bug c++/49118] New: Endless operator-> chain causes infinite loop potswa at mac dot com
                   ` (9 preceding siblings ...)
  2011-07-01  0:56 ` jason at gcc dot gnu.org
@ 2013-02-25 22:45 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-02-25 22:45 UTC (permalink / raw)
  To: gcc-bugs


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |basil at list dot ru

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-02-25 22:45:10 UTC ---
*** Bug 56449 has been marked as a duplicate of this bug. ***


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