catching integer divide by zero in C code

catching integer divide by zero in C code

Post by Doug To » Fri, 14 Aug 1992 04:49:18



If I look at the assembler generated for an integer divide statement by the
AIX Fortran compiler I see the following:

        teqi   r0,0x0
        divs   r0,r4,r0

In C code however, the teqi instruction is missing.  This is the instruction
that checks for an integer divide by zero and traps if one is seen.

Looking through the documentation for the C compiler I don't see any way to
generate the integer divide by zero check (-qflttrap is similar but is only
for floating point).  Am I missing something?  Is there any way to do this?

--
Doug Tody       National Optical Astronomy Observatories

 
 
 

catching integer divide by zero in C code

Post by Mark Mende » Fri, 14 Aug 1992 20:48:28


Use the -qcheck option to check for integer division by 0.
--
Mark Mendell
IBM Toronto Lab