From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27532 invoked by alias); 23 May 2011 00:47:25 -0000 Received: (qmail 27523 invoked by uid 22791); 23 May 2011 00:47:25 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 May 2011 00:47:11 +0000 From: "potswa at mac dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/49118] New: Endless operator-> chain causes infinite loop X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: potswa at mac dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Date: Mon, 23 May 2011 02:56:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg02022.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D49118 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 {=20 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 =E2=80=98struct = a<500>=E2=80=99