Bug: assertion "only C++ supports non-constant static initializers!"

Hi,

with clang r63301, I get the following assertion failure:

clang: CGDecl.cpp:93: llvm::GlobalValue*
clang::CodeGen::CodeGenFunction::GenerateStaticBlockVarDecl(const
clang::VarDecl&, bool, const char*): Assertion
`getContext().getLangOptions().CPlusPlus && "only C++ supports
non-constant static initializers!"' failed.

A test source and the full error message is attached.

The error occurs only if the first element of "struct foo" is a
pointer and only the second one gets explicitly initialized.

Max

test.c (133 Bytes)

error.log (2.43 KB)

Hi Max,

Thanks for the bug report. If it is no trouble, please file an actual Bugzilla PR (link off the clang website) so that we can track the resolution of this issue. While sending these reports to the mailing lists is fine, if the issue isn't resolve immediately it can easily get forgotten.

Ted

with clang r63301, I get the following assertion failure:

clang: CGDecl.cpp:93: llvm::GlobalValue*
clang::CodeGen::CodeGenFunction::GenerateStaticBlockVarDecl(const
clang::VarDecl&, bool, const char*): Assertion
`getContext().getLangOptions().CPlusPlus && "only C++ supports
non-constant static initializers!"' failed.

A test source and the full error message is attached.

Thanks!

The error occurs only if the first element of "struct foo" is a
pointer and only the second one gets explicitly initialized.

This is related to my changes to semantic analysis for designated initializers. I've fixed the assertion here:

  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090126/011516.html

However, this code now gives an

   error: cannot codegen this constant expression yet

since we're missing codegen for this case.

  - Doug

Confirmed, this is fixed, replaced by the other error message!

Will use Bugzilla next time, didn't notice that you have one...

Anyway, keep up the good work, I hope clang will be a full-featured
gcc replacement one day, sounds like a very interesting project.

Max