Re: C code working using CC but not with gcc

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

 



Hi Siva Prasad

Thanks a lot for your quick response.

This is a sample c code that i ve posted here. Actually we have 100k LOC of
such code in our application.
and we have so many such uninitialized variable in that code.

But this is code was working fine in AIX server and we ported and compiled
the same in HP we meet with Memory Fault error.

Do you have any solution for this?

Thanks.


Sivaprasad.pv wrote:
> 
> Hi karthikeyan,
>   I have checked with gcc, it is working fine( means, I not getting any 
> memory fault issue).
> According to my knowledge 'x' is uninitialized local pointer variable 
> (as we know for local variable space is allocated  in stack not in bss 
> section).
> As per ur code  x is pointing to some garbage location which may or may 
> not valid location and ur dereferencing it.
> So I think ur  the  code execution depend on which garbage location   x 
> is pointing to.
> 
> --P.V.Siva Prasad.
> 
> gkarthi29 wrote:
>> Hi All
>>
>> consider the following c code,
>>
>> #include<stdio.h>
>> main()
>> {
>>         char *x;
>>         if (*x==NULL)
>>         {
>>                 printf("hello");
>>         }
>> }
>>
>> the code prints "hello" if i compile using CC....
>>
>> but when i compile the same code using gcc it gives "Memory
>> fault(coredump)"......
>>
>> Why is it so? Do i need to include any extra options in gcc to make it
>> work?
>>
>> My objective it to make the above code work using gcc without any code
>> change....
>>
>> Kindly Suggest...
>>
>> Thanks.
>>   
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/C-code-working-using-CC-but-not-with-gcc-tp16738838p16739099.html
Sent from the gcc - Help mailing list archive at Nabble.com.


[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