
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Common undefined behaviours in C++ programming
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
- Related Articles
- What are all the common undefined behaviours that a C++ programmer should know about?
- Undefined Behaviour in C and C++
- What Are Some Common Beginner Mistakes in Java Programming?
- Is segmentation fault actual undefined behavior in C++?
- Undefined in JavaScript
- What are common Python programming mistakes programmers do?
- What are common programming errors or 'gotchas' in Python?
- Difference between undefined, unspecified, and implementation-defined behavior in C and C++?
- What are undefined reference/unresolved external symbol errors in C++?
- Socket Programming in C#
- Functions in C programming
- Stringstream in C++ programming
- isnormal() in C++ Programming
- Constructors in C++ Programming
- Undeclared vs Undefined? In JavaScript

Advertisements