Details
Description
The issues is not raised if the value is moved from the optional as follows:
if (arg.has_value()) { i = std::move(arg.value()); // same for operator* } else { i = -1; } (void)i;
However, we raise issue (I think correctly) on:
if (arg.has_value()) { i = std::move(arg).value(); // same for operator* } else { i = -1; } (void)i;
The second case if the positive side-product of CPP-3085.
Attachments
Issue Links
- is related to
-
CPP-3085 S6023: Fix false-positive when different optional are checked and derefenced
-
- Closed
-
- relates to
-
RSPEC-6023 "std::optional" member function "value_or" should be used
- Active