It seems unclear, but there are claims that dereferencing a nullpointer is undefined behavior:
This note was in fact removed as the result of DR 1102 with the stated reasoning being that it was not undefined behaviour to dereference a null pointer.
indicates that it might be defined behavior.
General agreement seems to be that it is undefined behavior.
So. Is it fine to call cv::setBreakOnError(true), which is supposed to cause raising an Access Violation on error()? Its implementation is as follows:
if(breakOnError)
{
static volatile int* p = 0;
*p = 0;
}
Or does calling this function mean, that due to undefined behavior, anything could now happen when my program is compiled and run?
My own best guess is that it is technically undefined but happens to always(?) do the right thing on windows and linux
std::breakpoint(C++26 onward), orboost::debug::debugger_break.&*p(wherephas a null pointer value) is not undefined because it does not actually fetch from memory ortypeid(*p), which is defined to throw an exception. So it is not merely having the lvalue*pin an expression that is undefined, and hence merely notionally dereferencing the null pointer value is not undefined. However, actually dereferencing the value in the sense many people might think, turning the pointer into a value (lvalue-to-rvalue conversion), is undefined.