in Education by
According to ISO C++, dereferencing a null pointer is undefined behaviour. My curiosity is, why? Why standard has decided to declare it undefined behaviour? What is the rationale behind this decision? Compiler dependency? Doesn't seem, because according to C99 standard, as far as I know, it is well defined. Machine dependency? Any ideas? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Defining consistent behavior for dereferencing a NULL pointer would require the compiler to check for NULL pointers before each dereference on most CPU architectures. This is an unacceptable burden for a language that is designed for speed. It also only fixes a small part of a larger problem - there are many ways to have an invalid pointer beyond a NULL pointer.

Related questions

0 votes
    I am coding a Gameboy Emulator, and for the CPU's instructions I use this struct here (in cpp.hpp ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    You can check to see whether an R object is NULL with the _________ function. (a) is.null() (b) is. ... and Debugging of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    I'm getting into user scripting with tampermonkey and can't get through this error, any help would be ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    What is (void*)0? Error re of null pointer re of void pointer none of the listed options? Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    What is the usage of the NULL pointer in C?...
asked Jan 21, 2021 in Technology by JackTerrance
0 votes
    What is the difference between an uninitialized pointer and a null pointer?...
asked Jan 21, 2021 in Technology by JackTerrance
0 votes
+1 vote
    What is NULL Pointer in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    What are the ways to a null pointer that can be used in the C programming language?...
asked Nov 8, 2020 in Technology by JackTerrance
0 votes
    When I do this: std::vector hello; Everything works great. However, when I make it a vector of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    After spending quite some time debugging the issue today, I noticed the boost::iostream::filtering_ostream ... #ifdef HAS_SCOPE { #endif ZlibOstream zlibOstream{oss}; zlibOstream...
asked May 1, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I want to improve the next code, calculating the mean: void calculateMeanStDev8x8Aux(cv::Mat* patch, int sx, int sy, int& ... the next loop with NEON intrinsics: for (int i=0; i...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    C and C++ distinguishes between declarations an definitions. You can declare a symbol many times, but you ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    C and C++ distinguishes between declarations an definitions. You can declare a symbol many times, but you ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
...