From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4628 invoked by alias); 25 Jan 2012 14:11:42 -0000 Received: (qmail 4616 invoked by uid 22791); 25 Jan 2012 14:11:41 -0000 X-SWARE-Spam-Status: No, hits=-2.9 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; Wed, 25 Jan 2012 14:11:28 +0000 From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/51998] New: compiler hangs on self-recursive alias attribute Date: Wed, 25 Jan 2012 14:39:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org 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 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: 2012-01/txt/msg02932.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D51998 Bug #: 51998 Summary: compiler hangs on self-recursive alias attribute Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned@gcc.gnu.org ReportedBy: vries@gcc.gnu.org inline-2.c: ... static void f (void) __attribute__((alias("f"))); void g () { f (); } ... hangs (with compiler build with r183325): ... $ gcc inline-2.c -O2 -S ... a mutually recursive version has the same problem: ... static void f (void) __attribute__((alias("g"))); static void g (void) __attribute__((alias("f"))); void h () { f (); } ... The compiler is stuck in this loop in cgraph_function_or_thunk_node: ... 1042 while (node) (gdb)=20 1044 if (node->alias && node->analyzed) (gdb)=20 1045 node =3D cgraph_alias_aliased_node (node); (gdb)=20 1042 while (node) ... The following tentative patch allows the compiler to abort compilation: ... Index: cgraph.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- cgraph.h (revision 183325) +++ cgraph.h (working copy) @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. #include "tree.h" #include "basic-block.h" #include "function.h" +#include "diagnostic-core.h" #include "ipa-ref.h" /* FIXME: inappropriate dependency of cgraph on IP= A.=20 */ enum availability @@ -1037,12 +1038,17 @@ cgraph_function_node (struct cgraph_node static inline struct cgraph_node * cgraph_function_or_thunk_node (struct cgraph_node *node, enum availability *availability) { + struct cgraph_node *start =3D node; if (availability) *availability =3D cgraph_function_body_availability (node); while (node) { if (node->alias && node->analyzed) - node =3D cgraph_alias_aliased_node (node); + { + node =3D cgraph_alias_aliased_node (node); + if (start =3D=3D node) + fatal_error ("function %q+D part of alias cycle", start->decl); + } else return node; if (node && availability) ... with an error message: ... $ gcc inline-2.c inline-3.c -O2 -S inline-2.c:1:13: fatal error: function =E2=80=98f=E2=80=99 part of alias cy= cle compilation terminated. inline-3.c:1:13: fatal error: function =E2=80=98f=E2=80=99 part of alias cy= cle compilation terminated. ...