Null pointer check elimination

sankar chebolu chnabsankar@yahoo.com
Tue Mar 8 10:49:00 GMT 2011


Dear Sir,
I am working with gcc 4.1.2 compiler in x86 system running Linux OS.
 
The following code snippet is taken from the link 'Global Null pointer test elimination', which appears in GCC-3.0 new features webpage.

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.

The expected assembly files with and without using the –fdelete-null-pointer-check has been provided in the same link. But while observing the compiler generated assembly, it is evident that the compiler is not eliminating the null-pointer check. 
Please advice.
Thanks & Regards,
Sankar






More information about the Gcc-help mailing list