public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Divide by Zero segment fault
@ 2012-10-18  1:44 Deepthi Bokka
  2012-10-18 18:06 ` Andrew Haley
  0 siblings, 1 reply; 2+ messages in thread
From: Deepthi Bokka @ 2012-10-18  1:44 UTC (permalink / raw)
  To: gcc-help

Hi,

I am new to this group and I am working on a project where I am porting the Diab build ECU software to GCC 3.4.4 version. This software actually works on MPC555 series of processor but I am removing all the hardware dependencies and creating the exe and dll so that it can run on Windows XP system. The dll will run on a proprietary tool to simulate the results.

But when I am running exe or dll, I am getting a segmentation fault because of divide by zero. To check for divide by zero in the software, code is very huge with many files and there are multiple places where this can occur. So checking for zero and skipping that is ruled out for my case.

But when the diab build software is running on MPC555 we are not getting this issue as there the compiler is handled differently. For example:
x = a/b where b=0 then this is processed as x=0 rather than giving error. So something by zero is treated as simply zero.

I want similar functionality even in GCC build code, is there any option for doing this. I tried the flag  -mno-check-zero-division in make file but I was getting make file error that this is not a valid flag. I tried using the signal handling "sigaction" but could not get the exact functionality as x/0 should be treated as 0. 

Please can any one help me how to handle this scenario, I can upgrade the GCC compiler version if higher versions can handle this issue. 

-Deepthi

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Divide by Zero segment fault
  2012-10-18  1:44 Divide by Zero segment fault Deepthi Bokka
@ 2012-10-18 18:06 ` Andrew Haley
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Haley @ 2012-10-18 18:06 UTC (permalink / raw)
  To: Deepthi Bokka; +Cc: gcc-help

On 10/16/2012 10:58 PM, Deepthi Bokka wrote:

> I am new to this group and I am working on a project where I am
> porting the Diab build ECU software to GCC 3.4.4 version. This
> software actually works on MPC555 series of processor but I am
> removing all the hardware dependencies and creating the exe and dll
> so that it can run on Windows XP system. The dll will run on a
> proprietary tool to simulate the results.
> 
> But when I am running exe or dll, I am getting a segmentation fault
> because of divide by zero. To check for divide by zero in the
> software, code is very huge with many files and there are multiple
> places where this can occur. So checking for zero and skipping that
> is ruled out for my case.
> 
> But when the diab build software is running on MPC555 we are not
> getting this issue as there the compiler is handled differently. For
> example: x = a/b where b=0 then this is processed as x=0 rather than
> giving error. So something by zero is treated as simply zero.
> 
> I want similar functionality even in GCC build code, is there any
> option for doing this. I tried the flag -mno-check-zero-division in
> make file but I was getting make file error that this is not a valid
> flag. I tried using the signal handling "sigaction" but could not
> get the exact functionality as x/0 should be treated as 0.
> 
> Please can any one help me how to handle this scenario, I can
> upgrade the GCC compiler version if higher versions can handle this
> issue.

Someone could probably figure out how to write a signal handler that
would do what you want, but it would be tricky and nonportable and
probably is not a good idea in any case.  Any division by zero is
almost certainly a bug that you should fix, and I would urge you to do
so.

Andrew.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-18  1:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18  1:44 Divide by Zero segment fault Deepthi Bokka
2012-10-18 18:06 ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).