Repository navigation
Java: Consider AssignOps in ArithExpr - #14254
Conversation
|
To consider while we're here: move out of Overflow.qll, probably to plain old Expr.qll? It seems like a generally useful category of expressions not particularly bound to the overflow queries. |
I considered it, but the Happy to do it as its own thing in a different PR if you think it makes sense though. |
|
I gave this a try in a query I'm working on that depends on the arithmetic assign operations and everything worked great. Looks good to me! |
|
Isn't this change potentially breaking this code? codeql/java/ql/lib/semmle/code/java/Conversions.qll Lines 126 to 133 in 3e1164f If we consider "Java Language Specification, Section 5.4." to actually refer to https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.6 then it does not list assignment arithmetic operators. |
|
I'm no expert, but a few ideas: What would The Java Language Specification is ambiguous in Section 5.4, but in Section 15.26.2 (Compound Assignment Operators) it states:
That makes it seem as though a compound arithmetic assignment operator (e.g. Testing with both javac 1.8.0_382 and javac 21 (21.0.0.35.1) (wrapped with Maven 3.8.4 via This program fails to compile with the error "incompatible types: possible lossy conversion from float to int": It looks as though |
|
Note that the compound assignment operator description says that Conversions-wise this means that There's also the potentially surprising situation of |
ArithExprwas considering unary and binary operators, but not compound operators, which are equally relevant for arithmetic-related questions. This PR addsAssignOps to the definition ofArithExprto address that.