Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!buffer2.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Sat, 22 Apr 2017 12:22:21 -0500 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: gcc failure (optimised/non-optimised) References: <58fb2265.5246218@news.xs4all.nl> <87o9voengz.fsf@gmail.com> Date: Sat, 22 Apr 2017 18:22:21 +0100 Message-ID: <87mvb84asy.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:C7sB56iaF2P9tjYnw3ZlC2cnJ/M= MIME-Version: 1.0 Content-Type: text/plain Lines: 22 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-ycV+fAYZeHWOeXlhBTUPg857/5x5vIzrCZud0SrIlaKU1fdscvTq+zUA782teQEBvlX//hgo7tSLHYf!1i+njX+517fTNap7ZopDHBOcK/trYkTN+XeixVhmTkDn9QbiPJvKeG3jvjsZQ9PQWq0fHkw= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1937 Xref: csiph.com comp.lang.c:108343 gazelle@shell.xmission.com (Kenny McCormack) writes: > In article <87o9voengz.fsf@gmail.com>, Gareth Owen wrote: >>James Harris writes: >> >>> IMO gcc is still at fault (and I use the term for a preference, not a >>> technical failure) for not reporting, by default, that the optimiser >>> was making an assumption. >> >>It's not an optimiser assumption, its a contract the programmer >>willingly enters into when they chose to write (correct) C. > > That is a stupid thing to say No it isn't. The assumption is that there's some integer for which (i < i + 1) is not true. And in C, as in actual mathematics, that's a **wrong** assumption. And UB is UB for the entire program. If you're unprepared to deal with the consequences of that, then you're going to get confused.