[LLVMbugs] [Bug 3269] New: clang::CompoundLiteralExpr::Init can be NULL, consequently getInitializer() must use cast_or_null.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Dec 29 02:46:40 PST 2008


http://llvm.org/bugs/show_bug.cgi?id=3269

           Summary: clang::CompoundLiteralExpr::Init can be NULL,
                    consequently getInitializer() must use cast_or_null.
           Product: clang
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: AST
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: bolzoni at cs.unipr.it
                CC: llvmbugs at cs.uiuc.edu, bagnara at cs.unipr.it


To see a case where CompoundLiteralExpr::Init is null:
- modify getSourceRange() adding `assert(Init && "Init CAN be null.");' as
first line of the function body.
- compile clang
- exec the new clang with this code:
---->
struct S {
  char a[2]; int b; };
int f() {
  return __builtin_offsetof(struct S, b); }
----<

The assertion will fail, and since the compound literal do not actually have an
init expression it is correct.
Yet, the getInitializer() functions use cast() that crashes in case of null
pointers. It must be changed to cast_or_null.


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