[cfe-dev] Local nonconstant initializer list codegen assertion failure

Steve Naroff snaroff at apple.com
Sun Jan 27 18:11:26 PST 2008


Totally legal (if you add -std=c99 to the gcc command line, the  
warning go away).

Looks like another bug in clangs code generation for initializers...

snaroff

On Jan 27, 2008, at 5:52 PM, Keith Bauer wrote:

> I don't know what the spec has to say about code like this, certainly
> GCC isn't without complaint, but generates "expected" code...
>
> CookieJar:Desktop keith$ cat test.c
> struct s { int i; };
>
> void foo(struct s a, struct s b) {
>    struct s A[2] = { a, b };
> }
>
> CookieJar:Desktop keith$ gcc -Wall -Wextra -pedantic -fsyntax-only  
> test.c
> test.c: In function 'foo':
> test.c:4: warning: initializer element is not computable at load time
> test.c:4: warning: initializer element is not computable at load time
> test.c:4: warning: unused variable 'A'
>
> CookieJar:Desktop keith$ clang -fsyntax-only test.c
>
> CookieJar:Desktop keith$ gcc -c test.c
>
> CookieJar:Desktop keith$ clang -emit-llvm test.c
> Assertion failed: (E && !hasAggregateLLVMType(E->getType()) &&
> "Invalid scalar expression to emit"), function EmitScalarExpr, file
> CGExprScalar.cpp, line 1031.
>
> -Keith
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list