Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Identify undefined behavior

...

Mismatches between arguments and conversion specifications may result in undefined behavior 163. Compilers may diagnose type mismatches in formatted output function invocations. In this noncompliant code example, the error_type argument to printf() is incorrectly matched with the s specifier rather than with the d specifier. Likewise, the error_msg argument is incorrectly matched with the d specifier instead of the s specifier specifier. These usages result in undefined behavior 163. One possible result of this invocation is that printf() will interpret the error_type argument as a pointer and try to read a string from the address that error_type contains, possibly resulting in an access violation.

...