C++ Logo

SG12

Advanced search

Subject: Re: [ub] A proposal to define signed overflow submitted?
From: Aaron Ballman (aaron_at_[hidden])
Date: 2018-03-14 17:50:57


On Wed, Mar 14, 2018 at 5:52 PM, Hyman Rosen <hyman.rosen_at_[hidden]> wrote:
> On Wed, Mar 14, 2018 at 5:37 PM, Aaron Ballman <aaron_at_[hidden]>
> wrote:
>>
>> On Wed, Mar 14, 2018 at 5:30 PM, Hyman Rosen <hyman.rosen_at_[hidden]>
>> wrote:
>> > No behavior should ever be designated undefined in order to allow
>> > optimizers to generate code by assuming that the behavior never occurs.
>>
>> Infinite loops are a counter-example to this assertion.
>
>
> How so?

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.

~Aaron


SG12 list run by herb.sutter at gmail.com