[Bug tree-optimization/95663] static_cast checks for null even when the pointer is dereferenced
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 15 10:04:24 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95663
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> I suppose the C++ standard says static_cast<Derived *>(nullptr) == nullptr
> and
> we literally follow that. Note it will make a difference for very large
> objects (and thus very large offsets added) which may end up acccessing
> actually
> mapped memory so IMHO what clang does by default is a security risk.
Is that any worse than this though?
LargeObject* p = nullptr;
p->foo();
Adding a static_cast doesn't seem to be the problem here.
More information about the Gcc-bugs
mailing list