Article View: comp.arch
Article #1011Re: reassociation and undefined behaviour
From: Dan Cross
Date: Tue, 01 Dec 2026 20:40
Date: Tue, 01 Dec 2026 20:40
59 lines
3723 bytes
3723 bytes
In article <11ena4h$24n1m$1@dont-email.me>, David Brown <david.brown@hesbynett.no> wrote: >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. Indeed. And we are taking it as a supposition that the rules are the same; as has been pointed out, Fortran doesn't have C's notion "undefined behavior", though I gather there is a similar construct. Regardless, without knowing Fortran better, I cannot say that they are exactly equivalent. - Dan C.
Technical Details
Message-ID:
<11enbci$qmj$1@reader2.panix.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mailReferences:
<11cpqih$acf5$1@dont-email.me> <11emcgn$1k681$1@dont-email.me> <11en8qf$nkd$1@reader2.panix.com> <11ena4h$24n1m$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.arch Subject: Re: reassociation and undefined behaviour Date: Tue, 1 Dec 2026 20:40:50 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <11enbci$qmj$1@reader2.panix.com> References: <11cpqih$acf5$1@dont-email.me> <11emcgn$1k681$1@dont-email.me> <11en8qf$nkd$1@reader2.panix.com> <11ena4h$24n1m$1@dont-email.me> Injection-Date: Tue, 1 Dec 2026 20:40:50 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="27347"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross)