home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gcc.bug
- Path: sparky!uunet!cis.ohio-state.edu!eos.ericsson.SE!etxmesa
- From: etxmesa@eos.ericsson.SE (Michael Salmon)
- Subject: Re: Bug in cygnus 2.0.1 (2.1 and 2.2.2 of mainstream)
- Message-ID: <1992Sep3.074701.4145@ericsson.se>
- Sender: gnulists@ai.mit.edu
- Reply-To: etxmesa@eos.ericsson.se (Michael Salmon)
- Organization: Ericsson Telecom AB
- References: <X3NgqB3w164w@kryton.UUCP>
- Distribution: gnu
- Date: Thu, 3 Sep 1992 07:47:01 GMT
- Approved: bug-gcc@prep.ai.mit.edu
- Lines: 50
-
- In article <X3NgqB3w164w@kryton.UUCP>,
- system@kryton.UUCP (Scott Beckstead) writes:
- |> I am currently porting a cygnus version of gcc (gpp objc etc.) to a new system.
- |> In my libraries (ansi) strcmp return -1 for less than, 1 for greater than and
- |> 0 for equality. The spec merely states negative for less than positive for greater
- |> than and 0 for equal. Yet in the file rtl.c There is a code fragment that
- |> looks like this
- |>
- |> if(!strcmp(somevalue,someothervalue))
- |> someaction;
- |>
- |> This seems like a particularly BAD idea considering the values returned by
- |> this fully ansi compliant library (yes it does change the behavior of
- |> the programs) I have modified my library to fix this but the code
- |> really should be fixed so that a unary not of a non boolean return
- |> is not used as a boolean. Because with the value -1 I'm sure you see the
- |> problem. (!(-1) is 0 but !(1) is -2 and !(0) is -1)
-
- I think that you are confusing ! with ~ as I hope that this shows.
-
- eos6c02 tmp 11 > cat testcode.c
- #include <stdio.h>
-
- int main()
- {
- int i;
-
- for ( i = -1; i <= 1; ++i)
- printf( "!(%2d) == %2d, ~(%2d) == %2d.\n", i, !i, i, ~i);
-
- return 0;
- }
- eos6c02 tmp 12 > testcode
- !(-1) == 0, ~(-1) == 0.
- !( 0) == 1, ~( 0) == -1.
- !( 1) == 0, ~( 1) == -2.
-
- In C, 0 is false everything else is true.
-
- --
-
- Michael Salmon
-
- #include <standard.disclaimer>
- #include <witty.saying>
- #include <fancy.pseudo.graphics>
-
- Ericsson Telecom AB
- Stockholm
-
-