Re: GCC Compilation problem in HP LINUX server

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

 



Sorry to disappoint you :) , but the HP C/C++ compiler (for
Itanium-based systems) allows you to control the behavior of NULL
pointer dereferences. Although out-of-topic for gcc, if you set the -Z
option, a NULL pointer dereference returns 0, while it returns a
"SIGSEGV" if you set -z.

This is probably the -Z option which gkarthi29 mentioned ... But, once
again, this is NOT gcc, and it is also NOT Linux!
 

Philip Herron wrote:
> gkarthi29 wrote:
>> Hi
>>
>> 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
>>
>>   
> Hey
>
> I have to agree with everyone else here, why would you de-referenced a
> null pointer to something which is un-defined. And then act on
> something which is un-defined.  Maby you could do *variable =
> something; then do what you want. It isn't anything to do with the
> compiler.
>
> If i had a compiler that let me run such a program i would be worried.
>
> --Phil
>


[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