Article View: comp.arch
Article #1010Re: reassociation and undefined behaviour
From: David Brown
Date: Tue, 01 Dec 2026 20:19
Date: Tue, 01 Dec 2026 20:19
49 lines
3699 bytes
3699 bytes
On 01/12/2026 20:57, Dan Cross wrote: > In article <11emcgn$1k681$1@dont-email.me>, > David Brown <david.brown@hesbynett.no> wrote: >> On 01/12/2026 00:54, Dan Cross wrote: >>> In article <11ejtoe$eoj7$1@dont-email.me>, >>> Thomas Koenig <tkoenig@netcologne.de> wrote: >>>> Dan Cross <cross@spitfire.i.gajendra.net> schrieb: >>>> >>>>> Rules for undefined behavior in Fortran obviously different from >>>>> those of C, since Fortran is a different langauge. >>>> >>>> Fortran has not concept of undefined behavior in the standard per se. >>> >>> It was pretty clear to me that the reference to UB in the ticket >>> you linked to was just a shorthand. >>> >>>> It has correct code, code that violates numbered constraints (which >>>> require a diagnostic) and code that violates a "shall" directive, >>>> which is errouneous but for which no diagnostic is required. >>>> >>>> Integer overflow is among the restrictions that a processor (Fortran >>>> standardese for the combination of compiler, run-time system etc) is >>>> not required to catch, a.k.a. the programmer's fault. And Fortran >>>> allows reassociation as long as parentheses are not violated. >>> >>> Ok. The point I was trying to make is that the context was not >>> C; it was Fortran. Thus, references to whatever C's UB rules >>> are don't really apply. >> >> While that's true, AFAIUI (and Thomas will hopefully correct me if I am >> wrong!) the Fortran rules for signed and unsigned integer arithmetic >> here are the same as for C. Fortran does not use the term "undefined >> behaviour", but the meaning is the same. And in this particular case, >> in both C and Fortran, addition is fully commutative and associative for >> both signed and unsigned types in the standard language. It is only >> when additional semantics are applied (such as trapping on overflow) >> that there is any difference. > > Perhaps that's so, but it is, again, besides the point that I > was making: suggesting that Thomas misunderstood the response on > the bug and citing the rules of C is ironic, when the context > was not C. > Agreed. Talking about C can make sense since a lot more people are familiar with the details of C than those of Fortran, but the post should have put in the connection (that the rules here are the same) rather than just changing languages.
Technical Details
Message-ID:
<11ena4h$24n1m$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.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> <11en8qf$nkd$1@reader2.panix.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.arch Subject: Re: reassociation and undefined behaviour Date: Tue, 1 Dec 2026 21:19:29 +0100 Organization: A noiseless patient Spider Lines: 49 Message-ID: <11ena4h$24n1m$1@dont-email.me> 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> <11en8qf$nkd$1@reader2.panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 01 Dec 2026 20:19:29 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2251830"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1caM7i7esOLqlHwWXruMYk2hA8k3QtEo="; posting-host="c0f3271de497b8d6a8f25db294917010" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:iNFRIuUv0S0LTIWb7Dm5bO0+y7Y= sha256:7kcppiRxrfr70uYLLw+j4IgdDyET8uOKMGFfl947o3g= sha1:HAjRvT2xCRq8a8trrOpcVn0qHnA= sha256:Xl06ZsVj7+TL98qFUIfw63vk8aCOQB/PDh988nF+gHs= Content-Language: en-GB In-Reply-To: <11en8qf$nkd$1@reader2.panix.com>