🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #1123

Re: reassociation and undefined behaviour

#1123
From: MitchAlsup
Date: Sun, 06 Dec 2026 02:22
37 lines
2881 bytes
Josh Vanderhoof <x@y.z> posted:

> Michael S <already5chosen@yahoo.com> writes:
> 
> > On Sat, 5 Dec 2026 23:09:58 +0100 Terje Mathisen 
> > <terje.mathisen@tmsw.no> wrote: 
> > 
> >> MitchAlsup wrote: 
> >> > anton@mips.complang.tuwien.ac.at (Anton Ertl) posted: 
> >> >    
> >> >> David Brown <david.brown@hesbynett.no> writes:   
> >> >>   
> >> >>> There are good reasons for such shifts being UB in C. 
> >> >>> Processors are not consistent in how out-of-range shifts 
> >> >>> are handled.  "x >> 32" might give 0 or it might give x.   
> >> >  How is x a useful result ?? EVER ???   
> >>  It is the result on all x86 cpus since the 386:  SHR/SHL x,n 
> >> are defined to first mask the shift count n by 31, so a shift 
> >> by 32 is exactly identical to a shift by 0.  
> > 
> > The same on Power - for 32-bit shifts count is masked by 31, for 
> > 64-bit shifts count is masked by 63. 
> > 
> >>  From other posts here, it seems that ARM also does masking but 
> >>  by 
> >> 255, ignoring any higher byte parts of the count.  
> > 
> > Only 32-bit Arm.  Aarch64 appears to be similar to x86 and 
> > Power. 
> 
> Why does everything do that instead of the more useful behavior? 
> Wouldn't it be pretty cheap to return 0 or the sign bit if any 
> bits past bit 5 are set?  Even in the 70's it doesn't seem like 
> that'd be such a big deal.

Everyone does not--my 66000 detects Operand Domain Error when
the shift amount is not between 0 and {size-1}. 
Technical Details
Message-ID: <1796523752-5857@newsgrouper.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail
References: <11cpqih$acf5$1@dont-email.me> <86o6b6kaqf.fsf@linuxsc.com> <11ejr5e$nk8$1@reader2.panix.com> <11ejtoe$eoj7$1@dont-email.me> <11el2c1$q43$1@reader2.panix.com> <11emcgn$1k681$1@dont-email.me> <jwvbj74bzm4.fsf-monnier+comp.arch@gnu.org> <11eolqn$2peg5$1@dont-email.me> <2026Dec2.132411@mips.complang.tuwien.ac.at> <11epd07$362ph$1@dont-email.me> <1796263648-5857@newsgrouper.org> <11ergn7$6utu$1@dont-email.me> <2026Dec3.122036@mips.complang.tuwien.ac.at> <1796326998-5857@newsgrouper.org> <11f223l$3cpaq$1@dont-email.me> <20261206003301.00002080@yahoo.com> <ygn4icrb5le.fsf@y.z>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail
From: MitchAlsup <user5857@newsgrouper.org.invalid>
Newsgroups: comp.arch
Subject: Re: reassociation and undefined behaviour
References: <11cpqih$acf5$1@dont-email.me> <86o6b6kaqf.fsf@linuxsc.com>
 	<11ejr5e$nk8$1@reader2.panix.com> <11ejtoe$eoj7$1@dont-email.me>
 	<11el2c1$q43$1@reader2.panix.com> <11emcgn$1k681$1@dont-email.me>
 	<jwvbj74bzm4.fsf-monnier+comp.arch@gnu.org>
 	<11eolqn$2peg5$1@dont-email.me>
 	<2026Dec2.132411@mips.complang.tuwien.ac.at>
 	<11epd07$362ph$1@dont-email.me> <1796263648-5857@newsgrouper.org>
 	<11ergn7$6utu$1@dont-email.me>
 	<2026Dec3.122036@mips.complang.tuwien.ac.at>
 	<1796326998-5857@newsgrouper.org> <11f223l$3cpaq$1@dont-email.me>
 	<20261206003301.00002080@yahoo.com> <ygn4icrb5le.fsf@y.z>
Date: Sun, 06 Dec 2026 02:22:32 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <1796523752-5857@newsgrouper.org>
Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user5857
Injection-Date: Sun, 06 Dec 2026 02:22:32 GMT
User-Agent: Newsgrouper/0.9.0