Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: Ivan Godard Newsgroups: comp.compilers Subject: Re: Implementation dependent behaviour (WAS: Re: Programming language and IDE design) Date: Wed, 08 Jan 2014 09:02:04 -0800 Organization: A noiseless patient Spider Lines: 29 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-01-007@comp.compilers> References: <13-11-025@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: leila.iecc.com 1389204268 36984 64.57.183.58 (8 Jan 2014 18:04:28 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Wed, 8 Jan 2014 18:04:28 +0000 (UTC) Keywords: design, architecture, arithmetic Posted-Date: 08 Jan 2014 13:04:28 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:1074 On 11/20/2013 2:29 AM, Martin Ward wrote: > (2) CPU designers may choose to implement that behaviour in hardware > on the next iteration of the CPU. Now the programs run fast on *all* > CPUs. > > Everybody wins. > > -- Martin I am such a CPU designer. We faced the "undefined" issue in our Mill family of general-purpose CPUs (ootbcomp.com). Not only are languages under-constraining, they are also sometimes over-constraining: signed integer overflow is undefined in C but required to wrap in Java. Our solution was to offer four hardware "overflow-behavior" options for every operation for which overflow is possible: modulo (wraparound), excepting, saturating, and double-width result (which cannot overflow). It is up to the compiler to choose the behavior to match the desired or mandated semantics. The other behaviors are also available via intrinsics. We also have a tool-chain option to force all non-explicit overflow behaviors to excepting throughout the program. It is truly astonishing how often "working" programs experience unanticipated (and previously unknown) overflow. For some value of "working". Ivan