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

             Bug #: 52806
           Summary: bogus "zero as null pointer constant" warning
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: akim.demai...@gmail.com


Well, I suppose that one could argue that this is not a bug,
but then it makes the feature much less useful.

I think that this warning should do nothing when std=c++11 was
not specified and therefore that nullptr is not supported.  Currently
G++ complains about 0 as a pointer even when it does not support
nullptr!

$ cat foo.cc
int *p1 = 0;
int *p2 = nullptr;

$ g++-mp-4.7 -Wzero-as-null-pointer-constant /tmp/foo.cc
/tmp/foo.cc:1:11: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
/tmp/foo.cc:2:11: error: 'nullptr' was not declared in this scope

$ g++-mp-4.7 --version
g++-mp-4.7 (GCC) 4.7.0 20120225 (experimental)
Copyright (C) 2012 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.

Reply via email to