[cfe-dev] Compound Literal semantic analysis...

Steve Naroff snaroff at apple.com
Fri Jan 11 14:26:09 PST 2008


On Jan 11, 2008, at 1:00 PM, Eli Friedman wrote:

> On Jan 11, 2008 12:34 PM, Steve Naroff <snaroff at apple.com> wrote:
>> In any event, now I understand why EDG/NEILCC allow my original
>> example (but not the revised example).
>
> I'm not sure I'm following... are EDG/NEILCC assuming that compound
> literals in initializers for static local variables have static
> storage duration?
> It doesn't appear to be a legal extension per the
> spec, because the spec explicitly states that because they are within
> a function body, such compound literals have automatic storage
> duration.  clang could do the same thing as EDG/NEILCC's as an
> extension, since it doesn't break any compliant C99 programs, but it
> doesn't seem like an especially useful extension...
>

Agreed. The spec is clear...the storage duration is determined by the  
location of the CompoundLiteral. If a compound literal within a  
function happens to be a constant expression, it still has automatic  
storage duration.

snaroff

> -Eli




More information about the cfe-dev mailing list