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

           Summary: malloc() fails to fail correctly at -O1 or above
           Product: clang
           Version: 2.6
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Basic
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


consider the following:

$ cat test.c
#include <stdlib.h>
#include <stdio.h>

int main() {
  size_t size = 0;
  size = ~size;
  int * a = malloc(size);

  if(a)
    printf("Successfully allocated %lX bytes of memory at %lX.\n",size,a);
  else
    printf("Failed to allocate %lX bytes of memory.\n",size);
}
$ clang -O0 test.c -o test.O0  && ./test.O0
Failed to allocate FFFFFFFFFFFFFFFF bytes of memory.
$ clang -O1 test.c -o test.O1  && ./test.O1
Successfully allocated FFFFFFFFFFFFFFFF bytes of memory at 7FD4D15BA010.

distro is Gentoo ~amd64. glibc is version 2.11 and compiled with gcc.

Apologies if this is a dupe, or caused by gcc compiled glibc conflicts. I'm not
quite sure exactly what to search for, but searching for 'malloc' didn't appear
to find anything relevant.


-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to