Boost logo

Boost :

Subject: Re: [boost] [outcome] Change semantics on UB from peer review agreed semantics?
From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2018-09-13 07:18:20

My 2 cents: The unexpected is always bad, so value() should NEVER be UB.

The arguments already came:

>> auto r = function().value();
>> and the other is
>> auto r = function();
>> if( r )
>> {
>> // use the value of `r`
>> }
Together with
> In the present Outcome you have both `value()` and `assume_value()`. In the
> default policy, with default `EC` the former throws and the latter is UB,
> but this is in general subject to policy, and if you are nasty, you can
> actually configure them the other way around, I think.
So you have `value()` for the 1st case which throws on valueless and
`assume_value()` which UBs on valueless.

Given that, the policy should only be there to decide WHAT exception to
throw and fail to compile for user-defined error types. The policy might
also NOT define any exception throwing in which case `value()` should be
unusable (compile error on use). This would make sense if you don't
allow any exceptions in your code and are always using the 2nd use case
instead. Note that the actual "throw" has to be in library code so no
one can accidentally create a policy that does not throw.

In any case: Even keeping the current design there should NOT be an
automatic switch to UB. But as detailed above overloading the
_semantics_ of `value()` is surprising and therefore bad.

Regard, Alex

Boost list run by bdawes at, gregod at, cpdaniel at, john at