Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Martin Ward Newsgroups: comp.compilers Subject: Re: Undefined Behavior Optimizations in C Date: Mon, 23 Jan 2023 17:12:14 +0000 Organization: Compilers Central Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <23-01-072@comp.compilers> References: <23-01-027@comp.compilers> <23-01-031@comp.compilers> <23-01-041@comp.compilers> <23-01-062@comp.compilers> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="74330"; mail-complaints-to="abuse@iecc.com" Keywords: C, optimize Posted-Date: 23 Jan 2023 13:27:46 EST 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:3340 On 18/01/2023 13:14, Spiros Bousbouras wrote: There's no assumption that UB (undefined behaviour) will not happen, both possibilities are accounted for. The "assumption that UB will not happen" is shorthand for the idea that any optimisation is valid if the optimised code is a refinement of the unoptimised code for all initial states such that UB does not occur. Equivalently, a proposed optimiation is valid if we represent UB as "abort" (a statement which can be refined to anything) and the optimised code is a refinement of the unoptimised code for all initial states. -- Martin Dr Martin Ward | Email: martin@gkc.org.uk | http://www.gkc.org.uk G.K.Chesterton site: http://www.gkc.org.uk/gkc | Erdos number: 4