On code blocks(C++)
#include
using namespace std;
int main(){
int *p;
cout<<*p;
}
produces garbage value
Your expectation of a runtime error is flawed.
Dereferencing an uninitialised/invalid pointer with arbitrary value can do anything at all.
That means the potential symptoms range from:
and so on.
This is true for dereferencing NULL, too, but modern commodity hardware tends to treat NULL dereferences specially, usually guaranteeing a segmentation fault to aid in diagnostics. Obviously, a CPU cannot do that for arbitrary pointer values, because they may be valid as far as it knows!