http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51998
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: [email protected]
ReportedBy: [email protected]
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)
1044 if (node->alias && node->analyzed)
(gdb)
1045 node = cgraph_alias_aliased_node (node);
(gdb)
1042 while (node)
...
The following tentative patch allows the compiler to abort compilation:
...
Index: cgraph.h
===================================================================
--- 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 IPA.
*/
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 = node;
if (availability)
*availability = cgraph_function_body_availability (node);
while (node)
{
if (node->alias && node->analyzed)
- node = cgraph_alias_aliased_node (node);
+ {
+ node = cgraph_alias_aliased_node (node);
+ if (start == 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 âfâ part of alias cycle
compilation terminated.
inline-3.c:1:13: fatal error: function âfâ part of alias cycle
compilation terminated.
...