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

--- Comment #4 from Iain Buclaw <ibuclaw at gcc dot gnu.org> ---
The D front-end doesn't set TREE_STATIC on the `__result` variable, it's
gcc/gimplify.cc at this location:

```
/* If a const aggregate variable is being initialized, then it
   should never be a lose to promote the variable to be static.  */
if (valid_const_initializer
    && num_nonzero_elements > 1
    && TREE_READONLY (object)
    && VAR_P (object)
    && !DECL_REGISTER (object)
    && (flag_merge_constants >= 2 || !TREE_ADDRESSABLE (object)
        || DECL_MERGEABLE (object))
    /* For ctors that have many repeated nonzero elements
       represented through RANGE_EXPRs, prefer initializing
       those through runtime loops over copies of large amounts
       of data from readonly data section.  */
    && (num_unique_nonzero_elements
        > num_nonzero_elements / unique_nonzero_ratio
        || ((unsigned HOST_WIDE_INT) int_size_in_bytes (type)
            <= (unsigned HOST_WIDE_INT) min_unique_size)))
  {
    if (notify_temp_creation)
      return GS_ERROR;

    DECL_INITIAL (object) = ctor;
    TREE_STATIC (object) = 1;     // <---
```

Reply via email to