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.