home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / gcc / bug / 3099 < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.4 KB  |  48 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!.UUCP!mitch
  3. From: mitch@.UUCP (Mitchell N. Perilstein)
  4. Subject: assignment from literal to double fails in 2.1
  5. Message-ID: <MITCH.93Jan2051743@clsi.clsi>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: CAD Language Systems, Inc.
  8. Distribution: gnu
  9. Date: Sat, 2 Jan 1993 10:17:43 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 35
  12.  
  13. Assignment with type conversion from a literal to a double is broken.
  14. gcc 2.1 on Sparc SunOS 4.1.2 and on RISC Ultrix 4.2 produces an
  15. unexpected result: 
  16.  
  17.     convert int to double: -2147483648 -> -2147483648.000000
  18.     convert lit to double: -2147483648 -> 2147483648.000000
  19.  
  20. I expected
  21.     
  22.     convert int to double: -2147483648 -> -2147483648.000000
  23.     convert lit to double: -2147483648 -> -2147483648.000000
  24.  
  25. The vendor /bin/cc gave the second result on both platforms. Here is the
  26. code. 
  27.  
  28. #define INT_MIN (-2147483648)    /* - (2^31) */
  29.  
  30. int main()
  31. {
  32.     double from_int, from_literal;
  33.     int i;
  34.  
  35.     i = INT_MIN;
  36.     from_int = i;
  37.     printf("convert int to double: %d -> %f\n", i, from_int);
  38.  
  39.     from_literal = INT_MIN;
  40.     printf("convert lit to double: %d -> %f\n", INT_MIN, from_literal);
  41. }
  42.  
  43. Respectfully,
  44. ---
  45.  Mitchell N. Perilstein   CAD Language Systems, Inc.   410-992-5700 x225 
  46.  Member, League for Programming Freedom.  Mail lpf@uunet.uu.net for info.
  47.  
  48.