A failure to issue a warning is not a refutement of the standard. As I said, yes obviously you can force it. You can force just about anything you want in C/C++.
But if you do
int& r = *((int*)0);
You'll find it will warn, and tell you that what you're doing is illegal:
<source>:2:14: warning: binding dereferenced null pointer to reference has undefined behavior [-Wnull-dereference]
Same if you try to naively return nullptr on a method that returns a reference:
int& iref() {
return nullptr;
}
<source>: In function 'int& iref()':
<source>:6:12: error: invalid initialization of non-const reference of type 'int&' from an rvalue of type 'std::nullptr_t'
But if you do
You'll find it will warn, and tell you that what you're doing is illegal:<source>:2:14: warning: binding dereferenced null pointer to reference has undefined behavior [-Wnull-dereference]
Same if you try to naively return nullptr on a method that returns a reference:
<source>: In function 'int& iref()':<source>:6:12: error: invalid initialization of non-const reference of type 'int&' from an rvalue of type 'std::nullptr_t'
Compiler returned: 1