Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C wish list Date: Fri, 22 Mar 2019 12:06:43 -0700 Organization: None to speak of Lines: 34 Message-ID: References: <11b51bdf-7847-40fc-bdf5-b3777f41b4da@googlegroups.com> <18RkE.296542$DH4.255445@fx24.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="7987eac78b6ba844db2ada674c778ee3"; logging-data="1145"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19pxic5OHd9g1OF8x0Y5h8J" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Uj0c1OH+g4V9nisi8jeSVqpw7cg= sha1:2fvKQVZbcSeB3/ioydWd2XRjKLU= Xref: csiph.com comp.lang.c:142255 David Brown writes: > On 22/03/2019 15:17, Malcolm McLean wrote: >> On Thursday, 21 March 2019 22:13:57 UTC, Keith Thompson wrote: [...] >>> 1 << 31 is undefined (assuming 32-bit int) for two reasons. >>> >>> 6.5.7p3: It's undefined because the right operand is greater than >>> or equal to the width of the promoted right operand. (0 << 31 is >>> undefined for the same reason.) >>> >>> 6.5.7p4: It's undefined because 1 * 2**31 is not representable in >>> the result type. (2<<30 is undefined for the same reason.) >>> >> Not really. It would make sense for > > I don't know what you mean by "not really" here. What Keith wrote is > correct (modified by Tim's reply - the width of "int" is 32, so 6.5.7p3 > does not apply and 0 << 31 is well defined). I also have no idea what Malcolm meant by "not really". Tim is correct, and I was not. I misremembered the meaning of "width" for signed integer types. The "width" includes the sign bit, so assuming 32-bit int, 1<<31 is undefined because the result is out of range, but 0<<31 is well defined. 0<<32 is undefined [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */