home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / bsd / 5755 < prev    next >
Encoding:
Text File  |  1992-09-15  |  1.5 KB  |  46 lines

  1. Newsgroups: comp.unix.bsd
  2. Path: sparky!uunet!wupost!udel!sbcs.sunysb.edu!sbcs!stark
  3. From: stark@cs.sunysb.edu (Gene Stark)
  4. Subject: Re: Program dies with FP Exception
  5. In-Reply-To: terry@thisbe.Eng.Sandy.Novell.COM's message of 15 Sep 92 15: 45:32 GMT
  6. Message-ID: <STARK.92Sep15193459@sbstark.cs.sunysb.edu>
  7. Sender: usenet@sbcs.sunysb.edu (Usenet poster)
  8. Nntp-Posting-Host: sbstark
  9. Organization: SUNY at Stony Brook Computer Science Dept.
  10. References: <STARK.92Sep13002650@sbstark.cs.sunysb.edu>
  11.     <1992Sep13.083846.6134@fcom.cc.utah.edu>
  12.     <1992Sep14.151555.12300@cs.few.eur.nl> <BuMMFx.Isq@Novell.COM>
  13. Date: Wed, 16 Sep 1992 00:34:59 GMT
  14. Lines: 30
  15.  
  16. I had asked about why my program was dying with an FP exception.
  17. I tried debugging again with a clearer head, and I found the problem source:
  18. a typedef with an unintended type in the source code.  However, the
  19. error should not have caused the exception--instead the program should
  20. have performed a double to int conversion and continued happily.  This may
  21. indicate a problem in the GNU C routine __fixdfsi.  If I get a chance
  22. I'll try to track this down.  What seems to happen is that the conversion
  23. from double to integer clobbers some locations it shouldn't be clobbering.
  24. The offending source code looked like this:
  25.  
  26. ------
  27. typedef struct AST_float {
  28.   int value;            /* I intended 'double' here */
  29. } AST_float;
  30.  
  31. main()
  32. {
  33.   AST_float *bar();
  34.   bar(3.0);
  35. }
  36.  
  37. AST_float *AST_make_float(v)
  38. double v;
  39. {
  40.   AST_float *f;
  41.  
  42.   f = (AST_float *) allocate(sizeof(AST_float)) ;
  43.   f->value = v;            /* Here is where the type mismatch is */
  44.   return(f);
  45. }
  46.