Divide by zero?

John Tytgat John.Tytgat at aaug.net
Sun Jan 2 11:14:50 PST 2005


In message <4d2709691asbellon at sbellon.de>
          Stefan Bellon <sbellon at sbellon.de> wrote:

> I have just noticed that when compiling with Norcroft and then linking
> against UnixLib there does not happen a "Divide by zero". E.g.:
> 
> #include <stdio.h>
> int main(void)
> {
>     int a = 5;
>     a /= 0;
>     printf("a = %i\n", a);
> }
> 
> This returns ...
> 
> a = 0
> 
> ... when compiled and linked against UnixLib but raises "Divide by
> zero" when compiled and linked against the SharedCLibrary.
> 
> Am I missing something obvious?

Not really but this has been the case for a very long time.

I also noticed this during my last signal related changes in UnixLib
but when I saw that this was already the case for a long time, I didn't
bother to change it.  But you're right, if SharedCLibrary does this, then
I think we should change UnixLib too.  Basically the fix will be in
__rt_sdiv (and __rt_udiv) routines.  Note that today a float/double division
by zero will raise.  I'll see if I can do that together with the other fix
needed to let UnixLib compile with Norcorft.

Incidently, does someone know if C99 specifies something in this area ?

John.
-- 
John Tytgat, in his comfy chair at home                                 BASS
John.Tytgat at aaug.net                             ARM powered, RISC OS driven



More information about the gcc mailing list