Path: csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: George Neuner Newsgroups: comp.compilers Subject: Re: Optimization techniques and undefined behavior Date: Wed, 08 May 2019 15:13:55 -0400 Organization: A noiseless patient Spider Lines: 44 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <19-05-070@comp.compilers> References: <19-05-014@comp.compilers> <19-04-021@comp.compilers> <19-04-023@comp.compilers> <19-04-037@comp.compilers> <19-04-039@comp.compilers> <19-04-042@comp.compilers> <19-04-044@comp.compilers> <19-04-047@comp.compilers> <19-05-004@comp.compilers> <19-05-008@comp.compilers> <19-05-014@comp.compilers> <19-05-021@comp.compilers> <19-05-037@comp.compilers> <19-05-049@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="7896"; mail-complaints-to="abuse@iecc.com" Keywords: standards Posted-Date: 08 May 2019 15:19:47 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:2305 On Tue, 7 May 2019 16:03:04 +0200, David Brown wrote: >If I write a function "square_root" in Go that takes a non-negative >input and returns its square root, then calling that function with a >negative input is undefined behaviour. That is splitting a fine hair. >It does not matter if it always has the same effect - if the behaviour >has not been specified, it is undefined. *You* specified the behavior by implementing the function. If you want to argue that there will never be wide spread agreement on the behavior, then ok ... but if you are want to argue semantics, then nothing that can be implemented can truly be "undefined". And if you really want to argue about "wide agreement", then language standards don't qualify - most programmers do not actively *agree* with the standard but simply choose to go along with it. For most the "choice" is made either by necessity - e.g., a business requirement to use the language - or simply by inertia or apathy [too big a deal to switch to a more "agreeable" language]. One data point: I will use C or C++ because I'm paid to do so, not because I like them or because I agree with the decisions made by their standards committees. Programming is NOT mathematics [or even mathematical in general] and there is no reason other than sanity that computer code should have to obey accepted physical or mathematical rules. And in fact, it doesn't: if it did, we wouldn't be having arguments about signed vs unsigned vs saturating vs wrap-around integers or how to deal with the difference between real numbers and floating point arithmetic. >Extrapolate that to any other aspect of any language, library, function, etc. When I do, I come to a completely different conclusion. YMMV, George