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

--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
On Fri, 15 Mar 2019, rick at regreer dot net wrote:

> But can you explain why:
> 
>      static char *foo[] = { (char []){"this compiles ..."} };
> 
>      void but() { static char *bar[] = { (char []){"this doesn't!"} }; }
> 
> I.e, why is the (char []) a non-constant element when it appears in a
> function?

A compound literal outside a function is an object with static storage 
duration, so has a constant address.

A compound literal inside a function is an object with automatic storage 
duration, so has an address (on the stack) only determined on entry to the 
function, so cannot be used in a static initializer.

Reply via email to