[Bug c++/56373] -Wzero-as-null-pointer-constant: does not catch issues with smart pointers
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 18 12:08:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56373
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-18 12:07:49 UTC ---
The warning isn't issued when 0 converts to std::nullptr_t, only when it
converts to a pointer type.
struct shared_ptr
{
shared_ptr(decltype(nullptr)) { }
~shared_ptr() { }
};
int main ()
{
shared_ptr a = 0;
shared_ptr b(0);
shared_ptr c{0};
}
(In reply to comment #0)
> It's also a bit sad that only d is diagnosed as useless, although I do
> understand that the shared_ptr has a constructor and a destructor that use
> it.
It's necessary, because otherwise you get bogus warnings from ScopeGuard-style
RAII types.
More information about the Gcc-bugs
mailing list