-Wbitwise-op-mismatch and enums of a matching type #1158
Replies: 2 comments
-
I suppose I can think of scenarios where you'd want to that to warn; like if the enum is not designed to be used as a mask / flags and the code accidentally uses the wrong enum, you'd want the warning to flag it. Like for example:
But I'd say I'm personally ambivalent. These warnings were originally added at user request because they wanted to get way more warnings about any expressions where the types were even a bit different, but I don't know how they'd react to this particular case and I do find them to be overly noisy already, so I wouldn't mind relaxing it for this case. |
Beta Was this translation helpful? Give feedback.
-
Your example is a good point. I do find bitwise-op-mismatch to be a useful warning and it has found a small number of real bugs. Will think through this a bit more. |
Beta Was this translation helpful? Give feedback.
-
Currently, if a variable of type bit[31:0] is used in a bitwise-operation with an enum that is also defined as type bit[31:0], then -Wbitwise-op-mismatch will flag a warning, e.g.
And the enum is defined as
Do you think it's reasonable to request a relaxation for enum bitwise operations where the enum type matches? Or is there a reason that someone might still want this to flag a warning?
Beta Was this translation helpful? Give feedback.
All reactions