Path: csiph.com!weretis.net!feeder4.news.weretis.net!border2.nntp.ams1.giganews.com!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Sat, 22 Apr 2017 05:37:05 -0500 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: gcc failure (optimised/non-optimised) References: Date: Sat, 22 Apr 2017 11:37:05 +0100 Message-ID: <87shl0enji.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:8ULHT/RDNhEV3RA3kcXNUkUL4Rg= MIME-Version: 1.0 Content-Type: text/plain Lines: 19 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-6inP9h1tbDOXhmsc4hhxY2NDAO2tWtRPYU9FcT5G2J4K/bCpgOftmlu3ud9oJk7BEQmB9zrCsQi5k8K!HwZlQoeEaRisWR1LTtvuDidA1P1o8YvE+lubD9aqgSCX4Vy9YbH5WycbeS4BSbBUK1t1URA= 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: 1777 Xref: csiph.com comp.lang.c:108334 James Harris writes: >> Overflow of signed integers is UB. Therefore "i < i + 1" can >> legitimately be simplified to true. >> >> Use -fwrapv if you want GCC/Clang to strictly consider signed integer >> overflow to have defined twos-compliment behaviour. >> >> http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html is >> an excellent set of articles which everyone should read. > > Thanks. That's very interesting. > > What gets me is that the compiler is (potentially) altering the > behaviour of the code without issuing a warning. That's true even with > -Wall -Wextra. The code does not have (defined) behaviour. Code whose behaviour is not defined, does not have to consistent modes of misbehaviour.