[LLVMbugs] [Bug 1889] New: clang allows allocating array that is too large

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Jan 1 00:03:16 PST 2008


           Summary: clang allows allocating array that is too large
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: AST
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu

void c(int n){
int b[ARR_SIZE];
int c[sizeof(b)-sizeof(int)*(long long)ARR_SIZE];

For this code, there should either be an error on the declaration of b (if
size_t isn't large enough to contain the size of b) or no error (if size_t is
large enough to contain the size of b).  Currently, there is an error claiming
that c has a negative width, which should be impossible since "sizeof(b)"
should be equal to "sizeof(int)*(long long)ARR_SIZE". Apparently, the
computation of sizeof(b) overflows.

For this code, gcc says "error: size of array ‘b’ is too large". clang
should say something similar.

Not sure if this is the right component.

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