Skip to content

Don't cast out-of-enum-range -1 to CommonIntegralTypes

Igor Kushnir requested to merge work/dont-cast-out-of-enum-range into master

This fixes the following Clang 16 compilation error:

kdevelop/plugins/clang/duchain/cursorkindtraits.h:217:7: error: integer value -1 is outside the valid range of values [0, 255] for the enumeration type 'CommonIntegralTypes' [-Wenum-constexpr-conversion]
    : static_cast<IntegralType::CommonIntegralTypes>(-1);

Quote from https://github.com/llvm/llvm-project/issues/59036 :

The -Wenum-constexpr-conversion warning was created to account for the fact that casting integers to enums outside of the valid range of the enum is UB in C++17. Constant expressions invoking UB lead to an ill-formed program.

BUG: 471995
FIXED-IN: 5.12.230800

Merge request reports