Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: gah4 Newsgroups: comp.compilers Subject: Re: what is defined, was for or against equality Date: Tue, 11 Jan 2022 14:18:56 -0800 (PST) Organization: Compilers Central Lines: 32 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-01-046@comp.compilers> References: <17d70d74-1cf1-cc41-6b38-c0b307aeb35a@gkc.org.uk> <22-01-016@comp.compilers> <22-01-018@comp.compilers> <22-01-020@comp.compilers> <22-01-027@comp.compilers> <22-01-032@comp.compilers> <22-01-038@comp.compilers> <22-01-041@comp.compilers> <22-01-044@comp.compilers> <22-01-045@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="48005"; mail-complaints-to="abuse@iecc.com" Keywords: standards, optimize Posted-Date: 11 Jan 2022 20:08:03 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <22-01-045@comp.compilers> Xref: csiph.com comp.compilers:2822 On Tuesday, January 11, 2022 at 11:47:26 AM UTC-8, Kaz Kylheku wrote: (big snip) > This leaves a lot of room for Fortran and C to have entirely different > defined/undefined behaviors. > Even the front end for one single language can have a lot of switches > affecting what is defined or not. I suppose so. But more usual, the compiler works to the least common denominator. For one, C requires static variables, and especially external ones, to initialize to zero, but Fortran doesn't. Fortran compilers that use C compiler middle and back ends, tend to zero such variables. I suspect that there are many more that I don't know about. As long as the cost is small, and it satisfies both standards, not much reason not to do it. Fortran has stricter rules on aliasing than C. I don't actually know about any effect on C programs, though, but it might be that compilers do the same for C. One that is not C or Fortran, but IEEE 754, is the effect of relational operators with NaN. Comparisons with NaN, except for "not equal", return false. That means that compilers have to be careful optimizing such, and especially that "greater than or equal" is not the logical complement of "less than". (I haven't looked at how compilers handle this, or, even more, how the hardware handles it.)