In computer programming, a program exhibits undefined behavior (UB) when it contains, or is executing code for which its programming language specification...
21 KB (2,635 words) - 14:08, 9 June 2025
Indeterminate form, in calculus Undefined behavior, computer code whose behavior is not specified under certain conditions Undefined value, a condition where...
1 KB (135 words) - 11:22, 10 May 2025
integer by casting then dereferencing the pointer to it is not valid (undefined behavior). This can be avoided by using alternative type punning techniques...
35 KB (4,648 words) - 02:43, 15 June 2025
multiplication by four. Shifts can result in implementation-defined behavior or undefined behavior, so care must be taken when using them. The result of shifting...
31 KB (3,832 words) - 16:45, 16 June 2025
It might do both at different times; or the comparison might be undefined behavior. Also, in languages offering such support, the correct use depends...
17 KB (2,076 words) - 17:07, 11 June 2025
unspecified, and undefined behavior. The exact definition of unspecified behavior varies. In C++, it is defined as "behavior, for a well-formed program...
6 KB (688 words) - 21:47, 22 May 2024
C syntax (section Undefined behavior)
the function is entered. The following expression, for example, has undefined behavior: printf("%s %s\n", argv[i = 0], argv[++i]); The C programming language...
85 KB (10,915 words) - 13:58, 11 June 2025
In mathematics, the term undefined refers to a value, function, or other expression that cannot be assigned a meaning within a specific formal system...
13 KB (1,506 words) - 22:07, 13 May 2025
standards specify that a C or C++ program containing a data race has undefined behavior. A race condition can be difficult to reproduce and debug because...
36 KB (4,513 words) - 15:53, 3 June 2025
memory allocation. Dereferencing a null pointer, which results in undefined behavior, will usually cause a segmentation fault. This is because a null pointer...
19 KB (2,431 words) - 08:02, 13 April 2025
Sequence point (section Behavior)
catastrophic undefined behavior if they share state. This situation can arise in parallel computations, causing race conditions, but undefined behavior can also...
9 KB (1,200 words) - 00:27, 13 March 2025
y to 10, and does not result in undefined behavior. let z = unsafe { x.baz }; // This results in undefined behavior, as the value stored in x is not...
20 KB (2,571 words) - 12:01, 11 September 2024
returned when the return statement is omitted, while in JavaScript the value undefined is returned. In Windows PowerShell all evaluated expressions which are...
20 KB (2,186 words) - 08:34, 20 December 2024
Integer overflow (section Inconsistent behavior)
signed integer overflow causes undefined behavior. Run-time overflow detection implementation UBSan (undefined behavior sanitizer) is available for C compilers...
28 KB (3,206 words) - 15:35, 14 April 2025
object is accessed by an independent pointer, this will result in undefined behavior. If the compiler knows that there is only one pointer to a memory...
7 KB (934 words) - 08:20, 10 May 2025
C++, some constructs are specified to have undefined behavior. A compiler is free to implement any behavior or none, and typically an optimizing compiler...
11 KB (1,322 words) - 20:04, 26 July 2024
between the format specifiers and count and type of values results in undefined behavior and possibly program crash or other vulnerability. The format string...
35 KB (3,072 words) - 14:06, 24 May 2025
compilers, it has generated some debate regarding whether this is undefined behavior according to the C standard, since it appears to involve a dereference...
8 KB (939 words) - 04:34, 15 March 2025
strcpy(str, input); // Copy input. // ... } The function will result in undefined behavior when the input is over 1000 characters. Some programmers may not feel...
14 KB (1,744 words) - 12:13, 10 May 2025
NULL: int *ptr = NULL; Dereferencing a null pointer in C produces undefined behavior, which could be catastrophic. However, most implementations[citation...
72 KB (9,678 words) - 04:54, 20 March 2025
value results in undefined behavior. For example, when shifting a 32 bit unsigned integer, a shift amount of 32 or higher would be undefined. Example: If...
16 KB (1,868 words) - 16:16, 31 March 2025
called.: §15.7.3 If that function is a pure virtual function, then undefined behavior occurs.: §13.4.6 This is true even if the class contains an implementation...
14 KB (1,656 words) - 04:10, 15 April 2025
(computer programming) Don't-care term Sequence point Side-channel attack Undefined behaviour Unspecified behaviour Frame problem Spuler, David A.; Sajeev...
10 KB (1,119 words) - 16:22, 16 November 2024
value of a numeric data type (often a floating-point number) which is undefined as a number, such as the result of 0/0. Systematic use of NaNs was introduced...
30 KB (3,755 words) - 00:04, 16 May 2025
try { typeid(*p); // Not undefined behavior; throws std::bad_typeid. } catch (...) { } Person& p_ref = *p; // Undefined behavior: dereferencing null typeid(p_ref);...
13 KB (1,450 words) - 15:12, 16 April 2025
race conditions and deadlocks (ThreadSanitizer), to detect undefined behavior (UndefinedBehaviorSanitizer), to detect memory leaks (LeakSanitizer), or to...
46 KB (4,900 words) - 20:46, 6 June 2025
value, without checking if the allocation is successful, invokes undefined behavior. This usually leads to crash (due to the resulting segmentation fault...
36 KB (4,141 words) - 17:14, 15 June 2025
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...
42 KB (5,688 words) - 19:44, 7 June 2025
translation or execution. In some cases, such programs may exhibit undefined behavior. Even when a program is well-defined within a language, it may still...
65 KB (7,415 words) - 08:02, 2 June 2025
operations should be performed. Such expressions generally invoke undefined behavior, and should be avoided. In languages with typed pointers like C, the...
11 KB (1,196 words) - 14:07, 24 May 2025