Re: Null pointer check elimination

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




foo (char *x)
{
 char ret = *x;

 if (x)
   com();
 else
   bar();
 return ret;
}

It is expected that the compiler will eliminate the pointer check with
the option '-fdelete-null-pointer-checks' or with >the option -O2, -O3, or -Os.

Hang on, why would it eliminate the null pointer check, if the null pointer check is in the source code? Are you assuming that the compiler knows for certain that x is non zero when it compiles the function?

Richard




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux