You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enum E {
E0 = 0x1,
E1 = 0x2,
E2 = 0x4
};
E operator&(E a, E b) { returnstatic_cast<E>(a & b); }
voidf(E e) {
if (e & E1) {}
}
<[source>:10:9: warning: conversion of 'E' into 'bool' will always return 'true', enum doesn't have a zero-value enumerator [bugprone-non-zero-enum-to-bool-conversion]
10 | if (e & E1) {}
| ^
[<source>:1:6: note: enum is defined here]
1 | enum E {
| ^
May produce false positives if the enum is used to store other values (used as a bit-mask or zero-initialized on purpose). To deal with them, // NOLINT or casting first to the underlying type before casting to bool can be used.
But I agree that this specific case probably could be excluded on check level.
Expect this to be fixed in Clang-tidy 18 timeframe.
https://godbolt.org/z/nv3PxYdM7
The text was updated successfully, but these errors were encountered: