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

Steve Naroff snaroff at apple.com
Fri Jan 11 11:38:23 PST 2008


On Jan 11, 2008, at 8:25 AM, Neil Booth wrote:

> Neil Booth wrote:-
>
>> Which agrees with GCC and seems pretty reasonable to me :)
>
> I meant EDG, not GCC.  In other words, why do you agree with
> GCC?
>

Agreeing with GCC (on a topic like this) isn't my goal. I'm simply  
trying to understand what the C99 spec requires.

I was surprised that EDG didn't conform to my interpretation of the  
spec. Since your front-end agrees with EDG, I'm glad I raised the  
issue...

My interpretation is simple. If an explicit variable with automatic  
storage duration is an error, then an implicit variable with automatic  
storage duration should be an error. Here is the example I provided  
earlier...

void a(void) {
int explicit;
int anylocal;
static int *t = &explicit;    // error for explicit automatic variables.
static int *a = (int[]){anylocal};    // implicit automatic variable.  
EDG and NEILCC permit this, while GCC error.
}

Is my analogy flawed? Since the compound literal can refer to any  
local variable, I don't see how it could ever be constant...

snaroff

> Neil.




More information about the cfe-dev mailing list