This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/65168] diagnostic: missing: reference cannot be bound to dereferenced null pointer


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

--- Comment #8 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #7)
> The diagnostic needs rewording, &r is not the address of a reference, it's
> the address of whatever the reference is bound to. Please don't add
> diagnostics that talk about something that has no meaning in the language.
> 
> It's not really relevant that r is a reference, &r takes the address of an
> object, so must be non-zero because you can't have an object with address
> zero.

Sure, I was trying to make the Clang message a bit more understandable. I got
completely confused by "pointer may be assumed to always convert to true" when
there is no pointer (in my last testcase).

What about "the address of the object bound to 'r' may be assumed to always
convert to true"?

I'm not sure if we can tell that 'r' is bounded to a dereferenced pointer at
the point of warning. If so, then it could print "because in C++ a reference
cannot be bound to a dereferenced null pointer", but this seems less important.

In any case, I just wanted to demonstrate that there is no "technical"
impediment to implement such a diagnostic in GCC. In fact, it is quite trivial.
That is, Clang does not have this warning because of some magic sauce in its
code, but simply because, for some reason, they have succeeded in attracting
developers who have the time to implement such things.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]