Path: utzoo!utgpu!attcan!uunet!vsi!friedl From: friedl@vsi.COM (Stephen J. Friedl) Newsgroups: comp.lang.c Subject: Re: question about shift operator Summary: Quoted from the standard... Message-ID: <926@vsi.COM> Date: 3 Nov 88 05:03:02 GMT References: <786@gtx.com> Distribution: na Organization: V-Systems, Inc. -- Santa Ana, CA Lines: 36 In article <786@gtx.com>, randy@gtx.com (Randy D. Miller) writes: > I've seen conflicting information about the shift operator in cases > where operand2 is exactly equal to the number of bits in the object. > E.g., with a 32 bit int, what must the following do? > > int n; > n <<= 32; > > K&R 1st ed. seems to indicate the operation is undefined, but does > the proposed standard change this? 3.3.7 Bitwise shift operators. Syntax: shift_expression: additive_expression shift_expression << additive_expression shift_expression >> additive_expression Constraints: Each of the operands shall have integral type. Semantics: The integral promotions are performed on each operand. 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. -- Steve Friedl V-Systems, Inc. +1 714 545 6442 3B2-kind-of-guy friedl@vsi.com {backbones}!vsi.com!friedl attmail!vsi!friedl ----Nancy Reagan on 120MB SCSI cartridge tape: "Just say *now*"----