Path: csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Hans-Peter Diettrich Newsgroups: comp.compilers Subject: Re: Bounds checking, Optimization techniques and undefined behavior Date: Sun, 5 May 2019 20:44:35 +0200 Organization: Compilers Central Lines: 15 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <19-05-029@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-020@comp.compilers> <19-05-024@comp.compilers> <19-05-025@comp.compilers> <19-05-028@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="27580"; mail-complaints-to="abuse@iecc.com" Keywords: errors, debug, comment Posted-Date: 05 May 2019 15:05:12 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:2264 Am 05.05.2019 um 12:14 schrieb Bart: > But how do they get there? Take this: > > int A[10], *p; > p = &A[3]; > > You intend p to refer to the 4-element slice A[3..6], but how does the > language know that? How can it stop code from writing to p[5]? Not pointers are bad, but pointer arithmetic is. It should be allowed only with objects of known bounds. DoDi [In this case the bounds look known to me. -John]