Integer overflow: Difference between revisions

Content deleted Content added
Security ramifications: Merged C and C++ into C/C++ as they are closely associated and identical in this regard.
Typo fixing, avoid redirects and alpha "See also", typo(s) fixed: For example → For example, using AWB
Line 16:
 
Since an arithmetic operation may produce a result larger than the maximum representable value, a potential error condition may result. In the [[C (programming language)|C programming language]], [[Signed number representations|signed integer]] overflow causes [[undefined behavior]], while unsigned integer overflow causes the number to be reduced [[modular arithmetic|modulo a power of two]], meaning that unsigned integers "wrap around" on overflow. This "wrap around" is the cause of the famous "[[kill screen|Split Screen]]" in Pac-Man.<ref>{{cite web|url=http://home.comcast.net/~jpittman2/pacman/pacmandossier.html|title=The Pac-Man Dossier|author=Pittman, Jamey}}</ref>
A "wrap around" corresponds to the fact, that e.g. if the addition of two positive integers produces an overflow, it may result in an unexpected result. For example, with unsigned 32 bit integers, 4000000000u + 1000000000u = 705032704u.
 
<!-- Diagram that illustrates wrapping behavior of integer representation. -->
Line 46:
| [[Smalltalk]] || NA || convert to LargeInteger
|-
| [[Swift]] || colspan="2 | Causes error unless using special overflow operators. <ref>The Swift Programming Language. Swift 2.1 Edition. October 21, 2015. </ref>
|-
|}
Line 57:
Run-time overflow detection implementation <code>AddressSanitizer</code> is also available for [[C compiler]]s.
 
{{mainMain article|AddressSanitizer}}
 
List of techniques and methods that might be used to mitigate the consequences of integer overflow:
Line 81:
 
==See also==
*[[Arithmetic underflow]]
*[[Arithmetic overflow]]
*[[Arithmetic underflow]]
*[[SIGFPE]]
*[[Buffer overflow]]
*[[Heap overflow]]
*[[Stack buffer overflow]]
*[[Pointer swizzling]]
*[[Software testing]]
*[[StaticStack codebuffer analysisoverflow]]
*[[Static program analysis]]
*[[Unix signal]]
 
==References==