Crashing in 32-bit but works on 64-bit

Ian Lance Taylor iant@google.com
Fri Jul 22 13:22:00 GMT 2011


Mitesh Thakkar <mail.mthakkar@gmail.com> writes:

> On Fri, Jul 22, 2011 at 3:09 PM, Mitesh Thakkar <mail.mthakkar@gmail.com> wrote:
>> Hi All,
>>
>> I have developed one custom application in C.
>> It is running fine in CentOS 5.6 64-bit, but it is crashing in CentOS
>> 5.6 32-bit.
>> I am not finding any reason/conclusion for it.
>> Can anyone help me for it.
>
> Interestingly, it is not crashing on 32-bit if I give -O0 (I mean do
> not optimize).
> What could be the reason.

I assume you are compiling with the -m32 option to generate 32-bit code.

You neglected to mention which version of gcc you are using.  You
neglected to mention what the crash looks like--e.g., is it a
segmentation violation or an illegal instruction?

While of course it could be anything at all, the most likely reason is
that your program is invalid C, and that the 32-bit optimizers are
changing it in a way that causes it to not behave as you expect.  If the
program works as you expect if you compile with -O2 -fno-strict-aliasing
-fno-strict-overflow then that is almost certainly the problem.

Ian



More information about the Gcc-help mailing list