https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127525

            Bug ID: 127525
           Summary: ICE: segfault in varpool_node::analyze /
                    cgraph_node::analyze after 'alias between function and
                    variable is not supported'
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: captainnemo9292 at gmail dot com
  Target Milestone: ---
            Target: x86_64-linux-gnu

An alias attribute whose target is a symbol of the other kind (variable
aliasing a function, or function aliasing a variable) is correctly diagnosed
by handle_alias_pairs ("alias between function and variable is not
supported"), but the node keeps its alias flag and analyze_functions then
dereferences the unresolved target.

Variable aliased to a function:

  int *a = 0;
  extern int *a __attribute__((alias("foo1")));
  int foo1() {}

  $ gcc -c t.c
  t.c:1:6: error: 'a' alias between function and variable is not supported
  cc1: internal compiler error: Segmentation fault
  varpool_node::analyze()
  symbol_table::finalize_compilation_unit()
  https://godbolt.org/z/zqqaa3xPP

Function aliased to a variable (here the alias is also on a definition):

  const char *__attribute__((alias("f0_target"))) a() {}
  const char *a();
  int f0_target;

  t.c:1:49: error: 'a' alias between function and variable is not supported
  t.c:1:49: internal compiler error: Segmentation fault
  cgraph_node::analyze()
  symbol_table::finalize_compilation_unit()
  https://godbolt.org/z/fT955f43h

gcc trunk 17.0.0 20260920, also gcc 13 (hidden behind "confused by earlier
errors, bailing out" in release-checking builds). PR79755 has a testcase of the
same shape using #pragma weak.

Reply via email to