GCC Compilation problem in HP LINUX server
Andrew Haley
aph@redhat.com
Tue Aug 4 10:51:00 GMT 2009
gkarthi29 wrote:
> Compiling the following program
>
> #include <stdio.h>
> int main()
> {
> char **variable=NULL;
>
> printf("Starting\n");
> fflush(stdout);
> while(*variable)
> {
> printf("Inside while\n");
> fflush(stdout);
> break;
> }
> printf("Ending\n");
> fflush(stdout);
> }
>
> Produces the output
>
> Starting
> Segmentation fault
>
> My System configuration is,
>
> Linux 2.6.9-55.0.2.ELsmp #1 SMP x86_64 x86_64 x86_64 GNU/Linux
> gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-8)
>
> basically i need to dereference NULL pointer in the above code.Is there any
> option available in Gcc?
No. Dereferencing a NULL pointer is always undefined behaviour.
Andrew.
More information about the Gcc-help
mailing list