Article View: comp.arch
Article #1078Re: reassociation and undefined behaviour
From: Anton Ertl
Date: Fri, 04 Dec 2026 18:08
Date: Fri, 04 Dec 2026 18:08
27 lines
2852 bytes
2852 bytes
EricP <ThatWouldBeTelling@thevillage.com> writes: >Why is signed twos's complement wrapping mathematically absurd? It's not. The question is if the programmer wants it. The existence of programs that behave with modular arithmetic as intended and don't behave as intended with other overflow behaviour shows that there are cases where programmers want it. And it has led to compiler maintainers adding -fwrapv as a way to telling that property of a program to the compiler. >I'm not a mathy but is it mathematically not just modulo arithmetic >with a relabelling of some values? There is no relabeling, just labeling. With the modulus m, any number x is congruent with all numbers x+nm, for any integer n; they form a congruence class, which is an equivalence class; i.e., all these numbers are equivalent with respect to the modulus m. You can label the congruence class of all these numbers with any of the numbers in the congruence class. One way to label the m congruence classes is with 0..m-1. But you can also label them with, e.g., (for even m) -m/2..m/2-1. Or in any other way. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID:
<2026Dec4.190839@mips.complang.tuwien.ac.at>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11cpqih$acf5$1@dont-email.me> <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> <11etu0b$1aih9$1@dont-email.me> <TlCQS.44884$7vt4.19168@fx07.iad>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.mb-net.net!open-news-network.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.arch Subject: Re: reassociation and undefined behaviour Date: Fri, 04 Dec 2026 18:08:39 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 27 Message-ID: <2026Dec4.190839@mips.complang.tuwien.ac.at> References: <11cpqih$acf5$1@dont-email.me> <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> <11etu0b$1aih9$1@dont-email.me> <TlCQS.44884$7vt4.19168@fx07.iad> Injection-Date: Fri, 04 Dec 2026 18:33:47 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1995617"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197uUvJ/32GzWGWNXhQW23Y"; posting-host="2d0b4d6fdd77f388e773fd7f60d00b18" Cancel-Lock: sha1:D57BxyXY73LpAy//TawfWTFkvL8= sha256:tMvJLCHhYLT6BS8uxUpQr/c++8wtzuODnpVgb2OKJ9A= sha1:xw2cbaWRGxKvY3/Ht1D27cVCJxg= sha256:25ia2aDUiEoRbSKYFzLQGQZquCqDk2V5FEwXkzHC/uY= X-newsreader: xrn 10.11