Bug list for Microsoft C

will summers will.summers at p6.f18.n114.z1.fidonet.org
Fri Jul 22 14:33:02 AEST 1988


 > In article <4516 at pasteur.Berkeley.Edu> iverson at cory.Berkeley.EDU.UUCP (Tim
 > Iverson) writes:
 > >int i=1, j=33;
 > >
 > >main() {
 > >    printf("%x\n", 1<<33);
 > >    printf("%x\n", 1>>33);
 > >    printf("%x\n", i<<j);
 > >    printf("%x\n", i>>j);
 > >}
 >
 > Under Xenix '386, I get: 2, 0, 2, 0;
 > 0.  So, anybody, what does ANSI say (in plain English)?
 
ANSI says as little as possible in plain English :8->
 
Actually (Jan '88 draft, pg 49) it says:
 
 "... If the value of the right operand is negative or is greater than or
  equal to the width in bits of the promoted left operand, the behavior is
  undefined."
 
So if int's on your implementation are less than 34 bits, a shift count of
33 don't pass ANSI muster.
 
Undefined behavior, under ANSI, means that the implementation is free to do 
just about anything, including non-deterministic behavior. Could even cause a 
"crash" and not be a "broken" compiler as far as ANSI is concerned.
 
Undefined behavior is a broader category than "implementation defined" 
behavior, which may vary from implementation to implementation, but must be 
deterministic (and documented) for each specific implementation.  The 
implication seems that "implementation defined" behavior precludes 
irrationalities like crashing, but that does not seem to me to be explicitly 
stated in the spec.
 
    \/\/ill
 
 
 
 


--  
St. Joseph's Hospital/Medical Center - Usenet <=> FidoNet Gateway
Uucp: ...ncar!noao!asuvax!stjhmc!18.6!will.summers
Internet: will.summers at p6.f18.n114.z1.fidonet.org



More information about the Comp.lang.c mailing list