[EMAIL PROTECTED] wrote:- > http://llvm.org/bugs/show_bug.cgi?id=2971 > > Summary: &((char*)0)[0] not regarded as static initializer > Product: clang > Version: unspecified > Platform: All > OS/Version: All > Status: NEW > Severity: normal > Priority: P2 > Component: LLVM Codegen > AssignedTo: [EMAIL PROTECTED] > ReportedBy: [EMAIL PROTECTED] > CC: [email protected] > > > The following code crashes clang: > > typedef struct FuncDef FuncDef; > struct FuncDef {}; > > void sqlite3RegisterDateTimeFunctions(void){ > static FuncDef aDateTimeFuncs = {((void*)&((char*)0)[0])}; > } > > > With the error message: > clang: CGDecl.cpp:86: llvm::GlobalValue* > clang::CodeGen::CodeGenFunction::GenerateStaticBlockVarDecl(const > clang::VarDecl&, bool, const char*): Assertion > `getContext().getLangOptions().CPlusPlus && "only C++ supports non-constant > static initializers!"' failed. > > (I'm not sure if this a duplicate or not. I have the strange feeling it's not > the first time I'm seeing this bug..)
It's not a bug; casts must be to arithmetic type (it would be nice if Clang were more explicit about the real problem, rather than just saying it's no good...). Neil. _______________________________________________ LLVMbugs mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs
