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 13:54:06 -0700 Organization: None to speak of Lines: 36 Message-ID: References: <11b51bdf-7847-40fc-bdf5-b3777f41b4da@googlegroups.com> <18RkE.296542$DH4.255445@fx24.am4> <2J7lE.185089$1p7.119303@fx05.am4> <2PalE.135956$Ef4.37063@fx38.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="7987eac78b6ba844db2ada674c778ee3"; logging-data="30299"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18D0Bf3u/ayfXHgcjGj4LJv" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:x3vg5owLMJ+OEGT5EyMX/kjJfjo= sha1:2C5NsyFWDhLSe4vyrP0RfzA7g6o= Xref: csiph.com comp.lang.c:142265 Bart writes: > On 22/03/2019 19:29, Keith Thompson wrote: >> Bart writes: [...] >>> Take my example, and say f() returns 0xFFFFFFFF_00000000 in 64-bit >>> register R0. The bottom half is stored to x, so x contains 0. >>> >>> The next line is: >>> >>> int32_t y = x>>8; >>> >>> because R0 could still contain 0xFFFFFFFF_00000000, David Brown is >>> suggesting that a compiler might make use of that existing value, and >>> because this processor only has 64-bit ops, it will right shift all 64 >>> bits to end up with 0x00FFFFFF_FF000000. >> >> I don't remember what David suggested. > > Read his posts today (Mar-22) at 13:26 and 15:10 GMT. He was trying to > explain why a machine with only 64-bit registers and operations (so > that intermediate calculations, even for int32, are necessarily > 64-bits) might give different results. David was discussing this example: int x = 1 << 31; int y = x / 5; which has undefined behavior (again, assuming 32-bit int). Your example does not have undefined behavior. Unless I've missed something, you are misrepresenting what David wrote. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */