Programming‎ > ‎C++‎ > ‎Programming Tips‎ > ‎Misc‎ > ‎

Undefined Behavior

The behavior of some constructs in C++ is literally not defined.
 
int *p = 0;                    // p is null pointer
std::cout << *p;            // dereferencing a null pointer, yields undefined behavior
 
char name[] = "Delta";     // name is an array of size 6, don't forget the trailling null
char c = name[10];         // referring to an invalid array index, yields undefined behavior
 
 
Comments