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: Sun, 25 Aug 2002 11:01:02 -0500

On Sunday 25 August 2002 08:27, Lars J. Aas wrote:
> Dirk Herrmann <address@hidden> 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?
> 
> I haven't studied the C specification under a microscope, but it has got
> to be a compiler bug.
    Nope.  It's a completely natural consequence or promoting signed to 
unsigned and the 2 values having the same storage size (and that being
the largest that will fit in a register).

>  What I guess is happening is that sizeof() is defined
> to return an unsigned value, and consequently -1 is interpreted as an unsigned
> value.  Exactly how data type qualifiers are supposed to propagate over unary
> tests isn't something I know for sure, but gcc handles it as one would expect.

    Well, I went back and looked at the original code versus what you said
it boils down to (the 3 lines).  With gcc, the first program returns true in 
both 
cases, but the 2nd (3 lines) prints "not so".  So gcc does get it right.  In the
original code you posted, the right hand side is cast to be a signed value
(scm_t_signed_bits) so it should get compared properly whether the left
hand side is signed or unsigned (and it does). 
     So I guess MSVC has a bug.
     As for the division by sizeof(char), though, I have no idea.  Maybe someone
was working with a non-standards-compliant compiler?

Lynn




reply via email to

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