[LLVMbugs] [Bug 5465] New: malloc() fails to fail correctly at -O1 or above

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Nov 11 12:47:07 PST 2009


           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: unassignedclangbugs at nondot.org
        ReportedBy: pigeon768 at hotmail.com
                CC: llvmbugs at cs.uiuc.edu

consider the following:

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

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

    printf("Successfully allocated %lX bytes of memory at %lX.\n",size,a);
    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.

More information about the llvm-bugs mailing list