*BSD News Article 5082


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel!munnari.oz.au!spool.mu.edu!wupost!udel!sbcs.sunysb.edu!sbcs!stark
From: stark@cs.sunysb.edu (Gene Stark)
Subject: Re: Program dies with FP Exception
In-Reply-To: terry@thisbe.Eng.Sandy.Novell.COM's message of 15 Sep 92 15: 45:32 GMT
Message-ID: <STARK.92Sep15193459@sbstark.cs.sunysb.edu>
Sender: usenet@sbcs.sunysb.edu (Usenet poster)
Nntp-Posting-Host: sbstark
Organization: SUNY at Stony Brook Computer Science Dept.
References: <STARK.92Sep13002650@sbstark.cs.sunysb.edu>
	<1992Sep13.083846.6134@fcom.cc.utah.edu>
	<1992Sep14.151555.12300@cs.few.eur.nl> <BuMMFx.Isq@Novell.COM>
Date: Wed, 16 Sep 1992 00:34:59 GMT
Lines: 30

I had asked about why my program was dying with an FP exception.
I tried debugging again with a clearer head, and I found the problem source:
a typedef with an unintended type in the source code.  However, the
error should not have caused the exception--instead the program should
have performed a double to int conversion and continued happily.  This may
indicate a problem in the GNU C routine __fixdfsi.  If I get a chance
I'll try to track this down.  What seems to happen is that the conversion
from double to integer clobbers some locations it shouldn't be clobbering.
The offending source code looked like this:

------
typedef struct AST_float {
  int value;			/* I intended 'double' here */
} AST_float;

main()
{
  AST_float *bar();
  bar(3.0);
}

AST_float *AST_make_float(v)
double v;
{
  AST_float *f;

  f = (AST_float *) allocate(sizeof(AST_float)) ;
  f->value = v;			/* Here is where the type mismatch is */
  return(f);
}