Using SonarQube version 2025.3
I have some false positives to report for this rule.
enum E : int
{
v1 = 0,
v2 = 1,
};
void func1()
{
auto e = E{};
// Suggests to use std::underlying as an intermediary when casting to an integer that is different from the underlying type
}
void func2(const int i)
{
auto e = E{i};
// Suggests to use std::underlying as an intermediary when casting to an integer that is different from the underlying type
}
Furthermore, I would like to request an exception when converting from std::byte
void func3(const std::byte b)
{
auto e = int{b};
// Suggests to use std::underlying as an intermediary when casting to an integer that is different from the underlying type
}