home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / amiga / programm / 17429 < prev    next >
Encoding:
Text File  |  1992-12-16  |  2.4 KB  |  56 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!caen!uvaarpa!concert!sas!mozart.unx.sas.com!walker
  3. From: walker@twix.unx.sas.com (Doug Walker)
  4. Subject: Re: Bug in SAS/C V6.1?
  5. Originator: walker@twix.unx.sas.com
  6. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  7. Message-ID: <BzCv72.MBF@unx.sas.com>
  8. Date: Wed, 16 Dec 1992 14:06:37 GMT
  9. Distribution: comp
  10. References: <S37732V.92Dec11104414@lk-hp-12.hut.fi> <Bz3nvr.82D@unx.sas.com> <8f=bT9K00hsBMrjYoD@cs.cmu.edu>
  11. Nntp-Posting-Host: twix.unx.sas.com
  12. Organization: SAS Institute Inc.
  13. Lines: 41
  14.  
  15.  
  16. In article <8f=bT9K00hsBMrjYoD@cs.cmu.edu>, Michael Witbrock <mjw+@cs.cmu.edu> writes:
  17. |> That depends on the type of  0.   If 0 is defined as a signed int, and
  18. |> the machine is an amiga, then it's the same, and it can demand that you
  19. |> do ~(unsigned short)0 .
  20. |> However, if this is the case, then it shouldn't let you do  unsigned int
  21. |> x = 5; either
  22.  
  23. No way.  5 can be converted from signed int to unsigned "losslessly" -
  24. i.e. the value is preserved.  Therefore, no warning.  -1 cannot be
  25. converted losslessly, so a warning is generated.
  26.  
  27. |> I'd tend to agree that this optimisation (~0 == -1) is producing the
  28. |> wrong results, and if it can't stop making the warning, it should
  29. |> evaluate the ~ at runtime.
  30.  
  31. The implementation is free to determine value ~0 has, but the standard
  32. mandates that the TYPE of the value is definately signed int.  On any 
  33. two's complement machine, ~0 is going to be -1, and that's what it is 
  34. on our implementation.  The real problem here is not that the value is
  35. -1, but rather that you have an overflow:  you are assigning
  36. 0xffffffff to something that can hold at most 0xffff.  You've lost
  37. the upper four f's.  The fact that the compiler prints the constant
  38. as -1 is an artifact of the given machine we're running on, but even
  39. on a one's complement machine there is precision lost here.
  40.  
  41. BTW, you can't evaluate the constant at runtime if it's a static
  42. initializer.  And would you REALLY want us to generate code for
  43. something that is, in the final analysis, merely a constant?
  44.  
  45. |> 
  46. |> michael
  47. -- 
  48.   *****
  49. =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
  50.  *|. o.| ||                                          1200/2400/9600 Dual
  51.   | o  |//     For all you do, this bug's for you!
  52.   ====== 
  53. usenet: walker@unx.sas.com                            bix: djwalker 
  54. Any opinions expressed are mine, not those of SAS Institute, Inc.
  55.  
  56.