Path: csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: George Neuner Newsgroups: comp.compilers Subject: Re: Optimization techniques and undefined behavior Date: Sat, 04 May 2019 17:44:02 -0400 Organization: A noiseless patient Spider Lines: 27 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <19-05-026@comp.compilers> References: <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-006@comp.compilers> <19-05-016@comp.compilers> <19-05-017@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="77178"; mail-complaints-to="abuse@iecc.com" Keywords: debug, errors, comment Posted-Date: 04 May 2019 18:32:15 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:2261 On Fri, 3 May 2019 10:52:27 +0100, Martin Ward wrote: >On 2019-05-01, David Brown wrote: >> Detecting signed overflow at run-time can be a significant cost. > >Firstly: the cost is not as high as the cost of security breaches due >to buffer overflows. Exactly. In well written code, often it is possible to amortize up-front limit tests over a substantial block of code. Similar to hoisting common subexpressions. >Secondly: if many popular languages specified >suitable handling for signed overflow, buffer overruns and so on, then >CPUs hardware would be developed which makes these tests efficient: >because compiled code in these popular languages would run faster on >such CPUs. Intel and AMD CPUs have bounds check instructions: but they are cumbersome (similar to using segments), cause exceptions rather than setting flags, and the instructions are relatively slow because few compilers ever used them. George [Are you referring to the old BOUND instruction or the newer MPX feature. -John]