[LLVMbugs] [Bug 6415] New: clang miscompile with -static and -O2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 24 12:41:05 PST 2010


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

           Summary: clang miscompile with -static and -O2
           Product: clang
           Version: trunk
          Platform: Other
        OS/Version: FreeBSD
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: hinokind at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=4303)
 --> (http://llvm.org/bugs/attachment.cgi?id=4303)
testcase

$ cat miscompile.c
#include <stdlib.h>

char * getenv (char const *name) {
    return "42";
}

int main()
{
    getenv("ABCDE");
}

$ clang miscompile.c -o bug && ./bug
no output

$ clang miscompile.c -O3 -o bug && ./bug
no output

$ clang miscompile.c -static -o bug && ./bug
bug: (malloc) Unsupported character in malloc options: ''
<last line ~40 more times>
bug: (malloc) Unsupported character in malloc options: 'E'

$ clang miscompile.c -O2 -static -o bug && ./bug
bug: (malloc) Unsupported character in malloc options: ''
<repeats this forever>

$ clang --version
clang version 1.1 (trunk 97041)
Target: x86_64-unknown-freebsd8.0
Thread model: posix


This is reproducable on multiple (FreeBSD) machines.
GCC behaves somewhat similar, though what -O{0-3} does depends on gcc version.

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