This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52806] New: bogus "zero as null pointer constant" warning
- From: "akim.demaille at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 31 Mar 2012 12:19:15 +0000
- Subject: [Bug c++/52806] New: bogus "zero as null pointer constant" warning
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: akim.demaille@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.