https://bugs.llvm.org/show_bug.cgi?id=50482

            Bug ID: 50482
           Summary: optimizer malloc
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

#include <stdlib.h>
int is_any_memory_available(int n){
    char *x = malloc(n);
    int y = (x != NULL);
    free(x);
    return y;
}

Works with -O0
With -O3 is optmized to 

is_any_memory_available:                # @is_any_memory_available
        mov     eax, 1
        ret


https://godbolt.org/z/4fr7Wz7n7

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to