[LLVMdev] bug or expected behaviour?

Carl Norum carl at lytro.com
Wed Jun 5 09:55:31 PDT 2013


On Jun 5, 2013, at 7:50 AM, John Regehr <regehr at cs.utah.edu> wrote:

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

OK, cool, thanks.

Why no warning or static analyzer error?  Other "this comparison is always true" or "this comparison is always false" warnings exist, right?

-- Carl





More information about the llvm-dev mailing list