This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Null pointer check elimination
"Michael N. Moran" <mike@mnmoran.org> writes:
| And what is the meaning of code that does this:
|
| int foo(int& a)
| {
| int* b = &a;
|
| if(b ==0)
| {
| a();
| }
| else
| {
| b();
| }
According to the standard, the compiler can assume that the test is
always false, therefore rewrite the if-else as an unconditional call to
b(). GCC already does some null-pointer check deleting.
-- Gaby