Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Undefined behavior
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Risks == C and C++ standards have several forms of undefined behavior throughout, which offer increased liberty in compiler implementations and compile-time checks at the expense of undefined run-time behavior if present. In particular, the [[International Organization for Standardization|ISO]] standard for C has an appendix listing common sources of undefined behavior.<ref>ISO/IEC 9899:2011 Β§J.2.</ref> Moreover, compilers are not required to diagnose code that relies on undefined behavior. Hence, it is common for programmers, even experienced ones, to rely on undefined behavior either by mistake, or simply because they are not well-versed in the rules of the language that can span hundreds of pages. This can result in bugs that are exposed when a different compiler, or different settings, are used. Testing or [[fuzzing]] with dynamic undefined behavior checks enabled, e.g., the [[Clang]] sanitizers, can help to catch undefined behavior not diagnosed by the compiler or static analyzers.<ref>{{cite web|title=Undefined behavior in 2017, cppcon 2017|author=John Regehr|website=[[YouTube]]|date=19 October 2017 |url=https://www.youtube.com/watch?v=v1COuU2vU_w}}</ref> Undefined behavior can lead to [[computer security|security]] vulnerabilities in software. For example, buffer overflows and other security vulnerabilities in the major [[web browser]]s are due to undefined behavior. When [[GNU C Compiler|GCC]]'s developers changed their compiler in 2008 such that it omitted certain overflow checks that relied on undefined behavior, [[CERT Coordination Center|CERT]] issued a warning against the newer versions of the compiler.<ref>{{cite web |archive-url=https://web.archive.org/web/20080409224149/http://www.kb.cert.org/vuls/id/162289 |url=http://www.kb.cert.org/vuls/id/162289 |archive-date=9 April 2008 |title=Vulnerability Note VU#162289 β gcc silently discards some wraparound checks |date=4 April 2008 |website=Vulnerability Notes Database |publisher=CERT}}</ref> [[Linux Weekly News]] pointed out that the same behavior was observed in [[PathScale|PathScale C]], [[Visual C++|Microsoft Visual C++ 2005]] and several other compilers;<ref>{{cite web |url=http://lwn.net/Articles/278137/ |date=16 April 2008 |author=Jonathan Corbet |title=GCC and pointer overflows |website=[[Linux Weekly News]]}}</ref> the warning was later amended to warn about various compilers.<ref>{{cite web |title=Vulnerability Note VU#162289 β C compilers may silently discard some wraparound checks |url=http://www.kb.cert.org/vuls/id/162289 |orig-year=4 April 2008|date=8 October 2008 |website=Vulnerability Notes Database |publisher=CERT}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)