Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2000:
[Freeciv-Dev] Re: 3 suspicous code parts
Home

[Freeciv-Dev] Re: 3 suspicous code parts

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Dirk Stoecker <stoecker@xxxxxxxxxxxxxxxxxxxxx>
Cc: Dirk Stoecker <stoecker@xxxxxxxxxxxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: 3 suspicous code parts
From: gs234@xxxxxxxxx (Gaute (B) Strokkenes)
Date: 07 Aug 2000 14:55:56 +0200

Dirk Stoecker <stoecker@xxxxxxxxxxxxxxxxxxxxx> writes:

> > > So the compiler removes the comparison. Either it must be == (u_long) -1
> > > or it has no effect:
> > > 
> > > warning 165 in line 193 of "server/meta.c": comparison redundant
> > > because operand is unsigned
> > 
> > Odd.  Shouldn't -1 be converted into 0xffffffff?  This is what the
> > code is meant to do, anyhow.
> 
> -1 is not 0xFFFFFFFF (at least not for all C compilers). The Motorola
> CPU's and also Intel I think have different commands for signed and
> unsigned comparissons. This sometimes obsoletes such checks totally, which
> is normally not wanted. Most time the compiler is clever enough to fix
> that, but not always :-)
> In this case nothing should happen as there is only one check command
> (BEQ.x) for equality checks, but who knows?

What I was thinking was that the LHS should be promoted to a signed
type, probably by copying the bit-pattern.  But then again, I can no
longer quote ANSI promotion rules from memory...

-- 
Big Gaute (not to be confused with LG)
Here I am in the POSTERIOR OLFACTORY LOBULE but I don't see CARL SAGAN
 anywhere!!



[Prev in Thread] Current Thread [Next in Thread]