Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Bart Newsgroups: comp.compilers Subject: Re: Optimization techniques and undefined behavior Date: Thu, 2 May 2019 18:59:21 +0100 Organization: virginmedia.com Lines: 43 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <19-05-013@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-045@comp.compilers> <19-04-049@comp.compilers> <19-05-003@comp.compilers> <19-05-009@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="96335"; mail-complaints-to="abuse@iecc.com" Posted-Date: 02 May 2019 14:18:38 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <19-05-009@comp.compilers> Content-Language: en-GB Xref: csiph.com comp.compilers:2249 On 02/05/2019 16:27, David Brown wrote: > On 01/05/2019 13:40, Bart wrote: >> (** This is the above program auto-translated from C to one of my >> languages, which is sort of interesting, this being a compiler group. >> > > Sure, your language is absolutely on-topic here. Don't forget this a compiler newsgroup not a C one, so examples of my language are just as relevant as C. 'Of interest' was a source-to-source translator that removes unnecessary macros, typedefs, #ifs and #includes from C source code. > But if you want to translate your language to C, you need to translate > it to C - not to what you think C ought to be. Read again - the translation goes the other way.   Given that you want your > own language to have wrapping semantics on integer overflow (hey, it's > your language - you define it in a crazy way if you want), You mean, like most processors, most languages and even most C compilers? Then yeah it's crazy. > What does not make sense, of course, is to run tests in C with undefined > behaviour and expect consistent or testable results.  That is just daft. That was sort of the point of my post - it's daft is for C to declare such code undefined behaviour, when the general consensus (see above) is that it can be perfectly well defined. >> The results match those of the non-gcc/non-clang C compilers (apart from >> speed which is poor).) > > Who cares?  The C code is buggy, so the results don't matter. The C is only buggy because C says so. My version is exactly the same program, and is not buggy because this language doesn't make unsigned overflow undefined behaviour.