May 1, 2014

[C++] Undefined Behavior, UB


  • Signed integer overflow (but not unsigned!)
  • Dereferencing NULL pointer or result of malloc(0) // 0 point to virtual memory 0 position. Also a reason why program start memory not 0.
  • Shift greater than (or equal to) the width of the operand
  • Reading from uninitialized variables
  • Modifying a variable more than once in an expression : Sequence point
  • Buffer overflow
  • Comparing pointers into two different data structures
  • Pointer overflow : GCC and pointer overflows
  • Modifying a const object (C++) or a string literal
  • Negating INT_MIN  : Why does -INT_MIN = INT_MIN in a signed, two's complement representation?
  • Data races
  • Mismatch between new and delete
  • Calling a library routine w/o fulfilling the prerequisites
  • memcpy with overlapping buffers // copy/copy_if , The source and destination ranges cannot overlap.
  • atomic_is_lock_free requires passing in obj shall not be nullptr
  • If during the evaluation of an expression, the result is not mathematically defined or not in the range of representable values for its type, the behavior is undefined.
clang -fsanitize=undefined

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.