Will throwing an exception for bad pointer access ever be standard behavior in C++? -
i did quick search on google , wasn't able find relevant exact topic.
as c++ continues move toward being more modern language, including lambdas, range based loops, etc, seems question may come up, if hasn't already.
i don't see how thing, , provide same benefits have been proven useful in c++/cli, c#, java, etc. , if didn't want behavior, made optional, , turned off compiler setting, same way 1 disable standard exceptions or rtti.
also, has been suggested, discouraged 1 create signal handler sigsegv , throw exception there, simulate suggested behavior. now, although bit of hack, , not guaranteed work on platforms, how hard implement null reference exceptions in c++ if same basic behavior can simulated(non-standardly) around 10 lines of code?
so, there reason technical, or otherwise, throwing exception bad pointer access couldn't become part of standard in future?
edit: answer question, 1 needs able see future accuracy. pretty easy short periods of time, longer, less gets. reply here should seen attempt foresee near future. whether happens in 20-30 years, can tell?
on 1 hand, technical perspective:
the problem null references 1 possible scenario of bad pointer. if stick random garbage pointer variable, or access memory after free, or else causes bad memory access cause sigsegv. that's first problem.
the second problem not hardware and/or software combinations allow detection of bad pointer access - or way continue after bad pointer access.
simply adding if (ptr != null) ...
before every pointer dereference [where compiler doesn't know sure valid pointer] make c++ unbearably slow.
from philosophical perspective, using raii: shouldn't use "raw" pointers in code, , new
cause std::bad_alloc
exception if system out of memory. there no reason why pointer should invalid in raii-style c++. if not using raii, should be.
c++ designed language fast first, , sophisticated second.