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

Steve Naroff snaroff at apple.com
Thu Jan 10 17:36:42 PST 2008


Folks,

Eli and I have been on improving clang's support for Compound Literals.

GCC and EDG produce different diagnostics for the following program.

void a(void) {
int tmp;
static int *t = &tmp;        // Both GCC and EDG issue an error  
diagnostic ("initializer element is not constant").
static int *a = (int[]){1}; // GCC issues an error diagnostic for this  
as well (but EDG allows it).
}

C99 6.5.2.5p6 says the following:

The value of the compound literal is that of an unnamed object  
initialized by the
initializer list. If the compound literal occurs outside the body of a  
function, the object
has static storage duration; otherwise, it has automatic storage  
duration associated with
the enclosing block.

This seems pretty clear to me...GCC is right and EDG is wrong.

Anyone disagree?

snaroff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080110/ec33e8ab/attachment.html>


More information about the cfe-dev mailing list