Not to be confused with Undefined value or Unspecified behavior.
In computer programming, undefined behavior (UB) is the result of executing a program whose behavior is prescribed to be unpredictable, in the language specification to which the computer code adheres. This is different from unspecified behavior, for which the language specification does not prescribe a result, and implementation-defined behavior that defers to the documentation of another component of the platform (such as the ABI or the translator documentation).
In the C programming community, undefined behavior may be humorously referred to as "nasal demons", after a comp.std.c post that explained undefined behavior as allowing the compiler to do anything it chooses, even "to make demons fly out of your nose".[1]
^"nasal demons". Jargon File. Retrieved 12 June 2014.
and 25 Related for: Undefined behavior information
In computer programming, undefinedbehavior (UB) is the result of executing a program whose behavior is prescribed to be unpredictable, in the language...
Indeterminate form, in calculus Undefinedbehavior, computer code whose behavior is not specified under certain conditions Undefined value, a condition where...
unspecified, and undefinedbehavior. The exact definition of unspecified behavior varies. In C++, it is defined as "behavior, for a well-formed program...
integer by casting then dereferencing the pointer to it is not valid (undefinedbehavior). Another way would be to place the floating point value in an anonymous...
example, has undefinedbehavior: printf("%s %s\n", argv[i = 0], argv[++i]); An aspect of the C standard (not unique to C) is that the behavior of certain...
multiplication by four. Shifts can result in implementation-defined behavior or undefinedbehavior, so care must be taken when using them. The result of shifting...
standards specify that a C or C++ program containing a data race has undefinedbehavior. A race condition can be difficult to reproduce and debug because...
signed integer overflow causes undefinedbehavior. Run-time overflow detection implementation UBSan (undefinedbehavior sanitizer) is available for C compilers...
that may be the case in practice. Dereferencing a null pointer is undefinedbehavior in C, and a conforming implementation is allowed to assume that any...
catastrophic undefinedbehavior if they share state. This situation can arise in parallel computations, causing race conditions, but undefinedbehavior can also...
memory allocation. Dereferencing a null pointer, which results in undefinedbehavior, will usually cause a segmentation fault. This is because a null pointer...
object is accessed by an independent pointer, this will result in undefinedbehavior. If the compiler knows that there is only one pointer to a memory...
returned when the return statement is omitted, while in JavaScript the value undefined is returned. In Windows PowerShell all evaluated expressions which are...
value results in undefinedbehavior. For example, when shifting a 32 bit unsigned integer, a shift amount of 32 or higher would be undefined. Example: If...
operations should be performed. Such expressions generally invoke undefinedbehavior, and should be avoided. In languages with typed pointers like C, the...
expression 0 0 {\displaystyle {\tfrac {0}{0}}} is also undefined. Calculus studies the behavior of functions in the limit as their input tends to some...
compilers, it has generated some debate regarding whether this is undefinedbehavior according to the C standard, since it appears to involve a dereference...
value, without checking if the allocation is successful, invokes undefinedbehavior. This usually leads to crash (due to the resulting segmentation fault...
executing f() concurrently do not result in a data race, which has undefinedbehavior in C and C++. The following C++ functions are impure as they lack...
C++, some constructs are specified to have undefinedbehavior. A compiler is free to implement any behavior or none, and typically an optimizing compiler...
set (otherwise the read has unspecified behavior). The same is syntactically valid but has undefinedbehavior in C++, however, where only the last-written...
the network with pages already loaded into its web browser, causing undefinedbehavior (for example, corrupt messages appear) when such a page tries HTTP...
sanitizer is a programming tool that detects bugs in the form of undefined or suspicious behavior by a compiler inserting instrumentation code at runtime. The...