Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes no requirements.

C99 Section 4 explains how the standard identifies undefined behavior. (see See also undefined behavior 1 of Annex J.):

If a "shall" or "shall not" requirement that appears outside of a constraint is violated, the behavior is undefined. Undefined behavior is otherwise indicated in this International Standard by the words "undefined behavior" or by the omission of any explicit definition of behavior. There is no difference in emphasis among these three; they all describe "behavior that is undefined".

...

An example of undefined behavior in C99 is the behavior on signed integer overflow. (see See also guideline INT32-C. Ensure that operations on signed integers do not result in overflow.) . This noncompliant code example depends on this behavior to catch the overflow.

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Other Languages

Related Guidelines

This rule appears in the C++ Secure Coding Standard as : MSC15-CPP. Do not depend on undefined behavior.

Bibliography

Wiki Markup
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 3.4.3, "undefined behavior," Section 4, "Conformance," and Annex J.2, "Undefined behavior"
\[[ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] "BQF Unspecified Behaviour", "EWF Undefined Behaviour" and "FAB Implementation-defined Behaviour"
\[[Seacord 052005|AA. Bibliography#Seacord 05]\] Chapter 5, "Integers"

...