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

Drea Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-06-24
            Summary|Inconsistent handling of    |-- with static bool
                   |static compound literals    |compound literal is
                   |                            |mishandled

--- Comment #2 from Drea Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

Maybe the bug is in gimplify_compound_literal_expr.

Here:
  /* Otherwise, if we don't need an lvalue and have a literal directly
     substitute it.  Check if it matches the gimple predicate, as
     otherwise we'd generate a new temporary, and we can as well just
     use the decl we already have.  */
  else if (!TREE_ADDRESSABLE (decl)
           && !TREE_THIS_VOLATILE (decl)
           && init
           && (fallback & fb_lvalue) == 0
           && gimple_test_f (init))
    {
      *expr_p = init;
      return GS_OK;
    }


There is no check on DECL_STATIC here.

Reply via email to