[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Please don't do this (code fragment)



In article <[🔎] 84vge2yuvl.fsf@rjk.greenend.org.uk>,
Richard Kettlewell  <rjk+nnews@sfere.greenend.org.uk> wrote:
>Who's to say that the computers (or even the compilers) of fifty years
>hence won't trap signed integer overflow?  Perhaps in the long term
>software quality would be higher on such systems.

Indeed.

In fact, I believe gcc already optimises on the basis that signed
integer overflow is undefined behaviour, though the loop which started
this thread is doubtless safe for the moment.

See the last comment in doloop_valid_p() in doloop.c:

<http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/gcc/gcc/gcc/doloop.c?rev=1.11.2.3&content-type=text/plain>

-M-



Reply to: