public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56373] New: -Wzero-as-null-pointer-constant: does not catch issues with smart pointers
@ 2013-02-18 11:35 akim.demaille at gmail dot com
  2013-02-18 12:08 ` [Bug c++/56373] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: akim.demaille at gmail dot com @ 2013-02-18 11:35 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56373

             Bug #: 56373
           Summary: -Wzero-as-null-pointer-constant: does not catch issues
                    with smart pointers
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: akim.demaille@gmail.com


Hi all,

Sorry if this report is bogus.  I would expect GCC to complain about the
following uses of 0 instead of nullptr, but it does not.

$ cat foo.cc
#include <memory>
struct foo {};

int main ()
{
  std::shared_ptr<foo> a = 0;
  std::shared_ptr<foo> b(0);
  std::shared_ptr<foo> c{0};
  foo *d = 0;
}
$ g++-mp-4.8 -std=c++11 -Wall -Wzero-as-null-pointer-constant /tmp/foo.cc 
/tmp/foo.cc: In function 'int main()':
/tmp/foo.cc:9:12: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
   foo *d = 0;
            ^
/tmp/foo.cc:9:8: warning: unused variable 'd' [-Wunused-variable]
   foo *d = 0;
        ^
$ g++-mp-4.8  --version
g++-mp-4.8 (MacPorts gcc48 4.8-20130210_0) 4.8.0 20130210 (experimental)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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.

Cheers!


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-02-20  9:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-18 11:35 [Bug c++/56373] New: -Wzero-as-null-pointer-constant: does not catch issues with smart pointers akim.demaille at gmail dot com
2013-02-18 12:08 ` [Bug c++/56373] " redi at gcc dot gnu.org
2013-02-18 12:53 ` akim.demaille at gmail dot com
2013-02-18 13:21 ` redi at gcc dot gnu.org
2013-02-18 13:23 ` akim.demaille at gmail dot com
2013-02-18 16:06 ` paolo.carlini at oracle dot com
2013-02-18 16:07 ` paolo.carlini at oracle dot com
2013-02-20  9:03 ` paolo at gcc dot gnu.org
2013-02-20  9:04 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).