[LLVMbugs] [Bug 2971] New: &((char*)0)[0] not regarded as static initializer

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Oct 28 17:05:25 PDT 2008


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: unassignedbugs at nondot.org
        ReportedBy: nunoplopes at sapo.pt
                CC: llvmbugs at cs.uiuc.edu


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..)


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list