Open smeenai opened 7 years ago
Looks like one need to look into AnalyzeCompoundAssignment()
in SemaChecking.cpp
While it does call AnalyzeImplicitConversions()
for the LHS/RHS,
it does not do anything to analyze whether the result is then demoted.
Given that AnalyzeImplicitConversions()
/CheckImplicitConversion()
explicitly expect the Expr
type to be the src
type, and passed QualType
to be the dst
type, and issue warnings based on their mismatch, they won't work,
because naturally the type of compound assign operator is the final type,
since the casts are hidden..
@lebedev.ri https://reviews.llvm.org/D53949 caught my eye (it turns out that's for a sanitizer, but it's a similar example of compound assignment operators not behaving like their decomposed versions). Do you have any insights here?
I've just been hit with this bug too. With operator |=
when accidentally* ORing a bit-64 constant into a 32-bit integer.
*When the code was originally written the constants were also 32-bit.
But without the compiler to tell me otherwise, I have no way of knowing if there are other instances of this in my code without checking each one by hand.
Extended Description
Compare to