guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SCM_POSFIXABLE(-1) fails with MSVC++ 6.0


From: Lynn Winebarger
Subject: Re: SCM_POSFIXABLE(-1) fails with MSVC++ 6.0
Date: Sat, 24 Aug 2002 10:57:52 -0500

On Saturday 24 August 2002 02:42, Dirk Herrmann wrote:
> 
> I am not sure I understand the problem here:  is the failure of testing 
> -1 <= sizeof(long) a compiler bug, or is the strange behaviour defined
> in the C language?

    It is mandated by K&R 2nd edition (Section A6).  When an expression
has and unsigned long and a signed long, the signed long is promoted to 
unsigned,
but without any change to the actual bit representation.  Thus -1 is 2^32-1, 
which
is clearly bigger than sizeof(long).  If you really want to compare to -1, cast 
the
unsigned to signed (since we know it'll fit in this case, and if promoted, will 
still give
the correct result (that is, if compared to an unsigned quantity, it will get 
recast to
unsigned, only this time the cast will get it right)).
     So gcc's probably wrong on this.  Apparently their optimization pass does 
its 
constant folding with a more accurate notion of integers than the machine code
has.
     It's possible this has been changed, but I would find it hard to believe 
as it
would change the semantics of so many programs.

Lynn
      




reply via email to

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