The following are most common causes of undefined behaviour in C++ programming. Note that all of these are specified in the standard to lead to undefined behaviour and should be avaoided at all costs when writing programs.
- Signed integer overflow
- Dereferencing a NULL pointer, a pointer returned by a "new" allocation of size zero, pointer that has not yet been definitely initialized, pointer at a location beyond the end of an array.
- Using pointers to objects which have gone out of scope or have been deleted
- Performing pointer arithmetic that yields a result outside the boundaries of an array.
- Converting pointers to objects of incompatible types
- Reading or writing to an object or array at an offset that is negative
- Making virtual function calls to pure virtual functions of an object from its constructor or destructor
- Not returning a value from a value-returning function