[LLVMdev] interesting possible compiler bug
clattner at apple.com
Mon Oct 15 17:20:21 PDT 2012
On Oct 15, 2012, at 2:28 PM, Krzysztof Parzyszek <kparzysz at codeaurora.org> wrote:
> On 10/1/2012 9:40 PM, Nick Lewycky wrote:
>> As far as I know, this optimization is legal.
> It's not legal.
> 1. malloc is not known to always return a non-null pointer.
> 2. malloc has side-effects and hence cannot be eliminated.
You've made a number of claims on this thread, but I'm not sure what you're basing these claims on - certainly not the C standard.
If you don't want the compiler to touch well known functions like malloc, build with -fno-builtin and you'll get the behavior you want.
More information about the llvm-dev