z390development / z390

z390 Portable Mainframe Assembler and Emulator Project
GNU General Public License v2.0
40 stars 15 forks source link

Incorrect usage of single | and & oprators #547

Open abekornelis opened 3 months ago

abekornelis commented 3 months ago

In java single | and & operators denote a bitwise or and bitwise and respectively. The double || and && are used to denote logical or and logical and.

In our java code the single, bitwise operators are used in many places where a double, logical operator is semantically required. Current counts across our java base indicate we have 1463 && operators and 1413 single & operators. Additionally we have 840 || operators and 449 single | operators. That leaves us with almost 2000 instances to investigate, correct, and test.

For now: low priority. If we encounter any such coding issues during maintenance, please correct those coding errors while the routine needs to be fixed and tested anyway.

Example from https://stackoverflow.com/questions/1795808/and-and-or-in-if-statements