[LLVMdev] bug or expected behaviour?

John Regehr regehr at cs.utah.edu
Wed Jun 5 07:50:33 PDT 2013


> The optimizer can therefore conclude that if this program has 
> well-defined behavior, then x can never point to the null pointer 
> constant (since the null pointer constant is not part of any array 
> object). As a result, the "if (!x)" branch would never trigger, and is 
> dead code.

This is correct: in C you can't create a null pointer by decrementing a 
valid pointer.  The code in question is dangerous and wrong, and needs to 
be reviewed to look for other similar problems.

John



More information about the llvm-dev mailing list