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

            Bug ID: 127528
           Summary: [17 Regression] ICE: tree check: expected var_decl,
                    have parm_decl in c_mark_addressable, subscripting a
                    flexible array member of a 'register' parameter
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: captainnemo9292 at gmail dot com
  Target Milestone: ---
            Target: x86_64-linux-gnu

Valid (if odd) C:

  struct s { int n; int b[]; };
  int c(register struct s d, int e) { return d.b[e]; }

  $ gcc -c t.c
  t.c:2:23: internal compiler error: tree check: expected var_decl, have
parm_decl in c_mark_addressable, at c/c-typeck.cc:6574
  tree_check_failed
  build_array_ref(unsigned long, tree_node*, tree_node*)
  c_parse_file()
  https://godbolt.org/z/YoGvfKoMM

Subscripting an array member requires taking the address of the
register-qualified struct, so build_array_ref calls c_mark_addressable. The
'register' branch there uses a VAR_DECL-only accessor (c-typeck.cc:6574),
but the object is a PARM_DECL. A fixed-size member (int b[4]) ICEs the same
way. gcc 13 rejects both with "address of register variable 'd' requested",
so this is a trunk regression.

Reply via email to