On 29 May 2013 14:35, Jens Maurer <Jens.Maurer@gmx.net> wrote:

 (1) Is a compiler diagnostic acceptable?  Yes.
 (2) Is a run-time abort acceptable?  Yes.
 (3) Is an unspecified result value acceptable?  Yes.
 (4) Is it acceptable that your compiler changes the behavior
of unrelated code that follows the overflow?  That's very surprising.

Giving compilers latitude to choose among 1-3 (depending on the
target audience) is fine, but, in my opinion, prohibiting option 4
would be an improvement.

The counter argument is usually that (4) has a run time cost in that the overflow must now be detected instead of just assumed that it cannot happen.  This effectively penalizes correct programs.

What does "behavior of unrelated code" even mean once we've invoked undefined behavior?
--
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404