Fix clang -Wpotentially-evaluated-expression warning
Status | Pipeline | Created by | Stages | Actions |
---|---|---|---|---|
Passed 00:29:33
| Stage: build Stage: test |
Download artifacts
No artifacts found |
With clang something like
std::unique_ptr<SomeBase> object{new SomeDerivation{}};
std::cout << typeid(*object).name() << '\n';
results in a warning like:
warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression] which is correct.
The fix is to change the code as:
std::unique_ptr<SomeBase> object{new SomeDerivation{}};
auto bare_ptr = object.get();
std::cout << typeid(*bare_ptr).name() << '\n';
i.e. make the evaluation explicit (since it's wanted).
Status | Pipeline | Created by | Stages | Actions |
---|---|---|---|---|
Passed 00:29:33
| Stage: build Stage: test |
Download artifacts
No artifacts found |