On Wed, Mar 28, 2018 at 07:47:53AM -0700, Manoj Gupta wrote: > Please note that there is nothing wrong in the generated code, just > that it confuses objtool. > Clang has simply omitted the statement where NULL is returned since > the pointer was always dereferenced post inlining.
... but returning NULL would be far more sane than falling through to the next function. > Note that GCC will also remove the NULL pointers if it knows that the > pointer is dereferenced. > Here is an example. > > void null_check(int *P) { > int deref = *P; > if (P == 0) // GCC won't check the condition. > return; > *P = 4; > } > > Compiling with gcc -O2 gives: > movl $4, (%rdi) > ret This is why we use -fno-delete-null-pointer-checks. -- Josh