Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Is this code considered to transgress the signed overflow purism? Date: Sun, 30 Apr 2017 14:25:04 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <11ea6682-cdee-4513-97c2-6c90b585716a@googlegroups.com> <87o9vi6rql.fsf@bsb.me.uk> <26aee5e9-ed2f-4c6e-af68-b85418c7e641@googlegroups.com> <6175390e-9ea6-45f9-bf8c-d87525c332da@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="518c2254bac820b1cb24a1d9d6a93e31"; logging-data="26684"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ds11XLxLxpk/h+h+jYQiT" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:WI6cCbJcQ9vRiAmPWEX2MfJA0pY= sha1:u3Nx9BM6tduhGxtlUw5zCWOor4c= Xref: csiph.com comp.lang.c:108810 Tim Rentsch writes: > supercat@casperkitty.com writes: >> On Friday, April 28, 2017 at 3:19:17 AM UTC-5, David Brown wrote: >>> The context here is C programming unless explicitly stated otherwise, >>> and in that context left-shifting a negative value is undefined. >> >> Did C89 become off-topic? In C89, left-shifting a negative value was >> defined in a way [...] > > As he is wont to do, supercat is talking out of school here. > Before the C99 standard, a left shift of a negative value > is not defined behavior but implementation-defined behavior. > Quoting the official response in DR 81: > > Subclause 6.3 states that the binary operator < , among > others, has implementation-defined aspects for signed types. > Therefore, the answer to ``What does it mean to left shift a > signed value?'' is that it is implementation-defined. It would be helpful if you'd Cite the DR you're referring to: http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_081.html (Note that the DR incorrectly refers to "<" rather than "<<", presumably a typo.) I'm not sure that supercat's interpretation is entirely unreasonable given what the C90 standard actually says. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"