![]() The preprocessor macro NULL is defined as an implementation-defined null pointer constant in, which in C99 can be portably expressed as ((void *)0) which means that the integer value 0 converted to the type void* (pointer to void). In C, two null pointers of any type are guaranteed to compare equal. It is one of the most common types of software weaknesses, and Tony Hoare, who introduced the concept, has referred to it as a "billion dollar mistake". It might do both at different times or the comparison might be undefined behaviour.īecause a null pointer does not point to a meaningful object, an attempt to access the data stored at that (invalid) memory location may cause a run-time error or immediate program crash. It might compare equal to other, valid pointers or it might compare equal to null pointers. ![]() However, depending on the language and implementation, an uninitialized pointer may not have any such guarantee. Programs routinely use null pointers to represent conditions such as the end of a list of unknown length or the failure to perform some action this use of null pointers can be compared to nullable types and to the Nothing value in an option type.Ī null pointer should not be confused with an uninitialized pointer: a null pointer is guaranteed to compare unequal to any pointer that points to a valid object. In computing, a null pointer or null reference is a value saved for indicating that the pointer or reference does not refer to a valid object. ![]() Value indicating that a referenced dataset is invalid or doesn't exist ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |