https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79572

--- Comment #7 from janus at gcc dot gnu.org ---
(In reply to Markus Trippelsdorf from comment #2)
> You can use -fno-delete-null-pointer-checks as a workaround for this issue.

Thanks for the comment, that's very helpful.


> But the C++ standard makes it very clear that references cannot be null,
> otherwise you're invoking undefined behavior.

Fully agree. I'm not trying to argue that GCC should adapt to cope with shitty
code.

But: There is a pretty dramatic change in behavior from version 5 to 6, in the
sense that (bad) code that worked before suddenly stopped working. A warning is
good, but I'd argue that in this case it's really not enough.

So, yes, a runtime error would be the needed at least.

I know that detecting such cases at compile time cannot be done in general, but
for the case here, shouldn't it be possible to detect the dereferencing of a
NULL pointer at compile time, simply by looking at this one line?

f(*((int*) NULL));

Reply via email to