Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added dataflow-related NCCE

...

Code Block
bgColor#ffcccc
int x = 50;
x += (x << 2) + 1;

Noncompliant Code Example (Left Shift)

This noncompliant code example segrates arithmetic and bitwise operators by variables. The x variable participates only in bitwise operations, and y participates only in arithmetic operations.

Code Block
bgColor#ffcccc

int x = 50;
int y = x << 2;
x += y + 1;

This example is noncompliant because the actual data receives both bitwise and arithmetic operations performed on it, even though they are segregated into different variables.

Compliant Solution (Left Shift)

...

Code Block
bgColor#ccccff
byte[] b = new byte[] {-1, -1, -1, -1};
int result = 0;
for (int i = 0; i < 4; i++) {

  result = ((result << 8) | (b[i] & 0xff));
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f3b2cc823a13f22a-d95be7e7-4b5b475f-b405be8b-1656fdd98ee3893d86322ace"><ac:plain-text-body><![CDATA[

[[Steele 1977

AA. Bibliography#Steele 1977]]

]]></ac:plain-text-body></ac:structured-macro>

...