Xref: utzoo comp.lang.c:31726 comp.std.c:3570 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c,comp.std.c Subject: Re: shift left arithmetic Message-ID: <13803@smoke.BRL.MIL> Date: 10 Sep 90 16:08:58 GMT References: <2098@charon.cwi.nl> Followup-To: comp.lang.c Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 17 In article <2098@charon.cwi.nl> aeb@cwi.nl (Andries Brouwer) writes: >I stumbled over the following: 1<<32 produced 0, but >int a; a=1; a<<32 produced 1. (Of course the word length >of my machine is 32 bits.) >Now I can understand how these values come about, and >each is perfectly acceptable, but shouldnt static evaluation >of expressions produce the same answers as dynamic evaluation? NO. When your exceed the bounds of what is guaranteed for the language, well, there are simply no guarantees. This example produces explicitly undefined behavior, and the implementation is free to take whatever apparently random actions it pleases. Implementors note: y=0;...;x<