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