https://bugs.llvm.org/show_bug.cgi?id=44931
Bug ID: 44931
Summary: Invalid optimization involving malloc and pointer
aliasing
Product: clang
Version: 9.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
Sort of contrived, but this code:
int use_malloc(int * X, void ** R, size_t Sz)
{
*X = 42;
*R = malloc(Sz);
return *X;
}
is getting unconditionally optimized to return 42 on clang (not on gcc).
This is an invalid optimization considering that the function can be called
with use_malloc(&errno, ...) and malloc will set errno on failure.
Failing test case:
https://gcc.godbolt.org/z/sEEBpJ
--
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