Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Aug 1998 17:14:45 +0100 (BST)
From:      Tim Borgeaud <Tim.Borgeaud@bristol.ac.uk>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   RE: Why is my code failing with SIGFPE?
Message-ID:  <199808281614.RAA27907@zeus.bris.ac.uk>

next in thread | raw e-mail | index | archive | help
Apologies to all. I have managed to find the problem in my code.
 
I had missed out one of my include files. This had lead to a function being
implicitly declared rather than declared as a function returning a double.

After browsing the mail archives and some careful attention to compiling
I found the error. I forget who wrote the message that described this function
misdeclaration as a cause of SIGFPE. Thanks to whoever it was.

Is this kind of behaviour from the compiler unavoidable? It took me ages to
track down the bloody problem. As a novice programmer I was confused by the
floating point exception and spent a long time wondering how my variables could
have gone out of range.


> 
> Sorry if this is bit off topic but I think someone reading the list can
> probably help me.
> 
> I have some C-code which fails with floating point exceptions (SIGFPE errors).
> Code compiles cleanly, although I am not using any additional options to gcc.
> 
> I am stumped as to the cause of these errors. Depending on where I put 
> print statements in the code (for debugging purposes) it fails at different
> points.
> 
> The code makes fairly heavy use of the CPU and is recursive. On the fourth call
> of the recursive function the code fails with SIGFPE, sometimes in my code 
> without any reason that I can find, but also commonly in __dtoa (called during
> printf of a floating point number).
> 
> I have carefully gone through my code, sections of which seemed to be working
> perfectly on their own. I cannot seem to find anything wrong. I can supply all or
> parts of the code that I am trying to run if anyone is interested. I was hoping
> that someone may have come across this kind of thing before.
> 
> The code has also been compiled using djgpp under msdos and has the same
> problem. Two machines (Pentium and Pentium MMX) produce the same results.  
> 
> I have tried to use gdb, but because I have never used it before it didn't help
> very much. All I found was that some of the floating point variable were
> scrambled after the failure (eg some ridculous number x10^230 or something).
> 
> 
> Many thanks
> 
> Tim
> 
>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808281614.RAA27907>