...
Automated detection of integer operations that can potentially overflow is straightforward. Automatic determination of which potential overflows are true errors and which are intended by the programmer is infeasible. Heuristic warnings could be helpful.
Related Guidelines
"INT32-C. Ensure that operations on signed integers do not result in overflow" | ||||
"INT32-CPP. Ensure that operations on signed integers do not result in overflow" | ||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="aeb1027a4b068108-939cac8a-48c04279-8b0ba0b4-c21a9c3eba23fff3b0e59cd6"><ac:plain-text-body><![CDATA[ | [ISO/IEC TR 24772:2010 | http://www.aitcnet.org/isai/] | "Wrap?around Error [XYY]" | ]]></ac:plain-text-body></ac:structured-macro> |
CWE ID 682, "Incorrect Calculation" | ||||
| CWE ID 190, "Integer Overflow or Wraparound" | |||
| CWE ID 191, "Integer Underflow (Wrap or Wraparound)" |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="abb583b5b9b24375-7f3ca057-4c4e4e97-803a9add-c704062380b7a1ac7045ae9b"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | class [ | http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html] | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="fe7d4bd6a6521adf-80f59605-40cd4a49-96d99734-7129c60811fb9c472e69979a"><ac:plain-text-body><![CDATA[ | [[Bloch 2005 | AA. Bibliography#Bloch 05]] | Puzzle 27: Shifty i's | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e203a9fc5d22f057-bb397c83-445f4d5c-b62d8469-01eec1e21d7f7f16d8ecdc4a"><ac:plain-text-body><![CDATA[ | [[SCG 2009 | AA. Bibliography#SCG 09]] | Introduction | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b2bbf10263f05955-e8d657a4-40694b66-b95588b8-fad790e2057f5f813631409b"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#JLS 05]] | [§4.2.2, "Integer Operations" | http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.2] | ]]></ac:plain-text-body></ac:structured-macro> |
| |||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c17c8754c9d3b09c-e72982a7-4c974a04-b7c2aef7-df0895951deac10b2e40aea9"><ac:plain-text-body><![CDATA[ | [[Seacord 2005 | AA. Bibliography#Seacord 05]] | Chapter 5. Integers | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="95effe024e382d3c-000135d2-47c548ed-9f748684-b721483bf8efd76cd2cd2c07"><ac:plain-text-body><![CDATA[ | [[Tutorials 2008 | AA. Bibliography#Tutorials 08]] | Primitive Data Types | ]]></ac:plain-text-body></ac:structured-macro> |
...