Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ncar!noao!nud!asuvax!stjhmc!p6.f18.n114.z1.fidonet.org!will.summers From: will.summers@p6.f18.n114.z1.fidonet.org (will summers) Newsgroups: comp.lang.c Subject: Re: Bug list for Microsoft C Message-ID: <143.22E93D1C@stjhmc.fidonet.org> Date: 22 Jul 88 04:33:02 GMT Sender: ufgate@stjhmc.fidonet.org (newsout1.17) Organization: FidoNet node 1:114/18.6 - Iasd Eng Bbs, Phoenix Az Lines: 47 > In article <4516@pasteur.Berkeley.Edu> iverson@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< > 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@p6.f18.n114.z1.fidonet.org