C++ Logo

SG12

Advanced search

Subject: Re: [ub] A proposal to define signed overflow submitted?
From: Hyman Rosen (hyman.rosen_at_[hidden])
Date: 2018-03-15 00:24:06


On Wed, Mar 14, 2018 at 6:50 PM, Aaron Ballman <aaron_at_[hidden]>
wrote:
>
> Infinite loops are undefined behavior because you'd have to solve the
> halting problem in order to determine whether any given code path is
> dynamically reachable. So presence of an infinite loop is UB in order
> to allow optimizers to generate code assuming the behavior never
> occurs.

As soon as you mention the word "optimizer" you are lost.

Compilers don't need to solve anything. All they need to do is to model the
abstract machine on the underlying computer. If the abstract machine
executes
an infinite loop, so does the computer. As the programmer wrote it.



SG12 list run by herb.sutter at gmail.com