This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
- From: "paolo.carlini at oracle dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 17 Oct 2011 23:12:58 +0000
- Subject: [Bug c++/44277] [C++0x] Add warning to facilitate nullptr conversion.
- Auto-submitted: auto-generated
- References: <bug-44277-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44277
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-17 23:12:58 UTC ---
Jason, would it make sense to produce the warning in cp_convert_to_pointer? I
see the function does *not* have a complain argument (which would be used in
the existing error calls), and that is good because it means we should be safe
wrt undesired warnings in sfinae. Then, about the below, I guess we have also
to decide what to do wrt pointers to members: the same? Then, we'll have also
to decide the exact *name* of the warning... So many questions ;)
////////////
--- cvt.c (revision 180110)
+++ cvt.c (working copy)
@@ -209,7 +209,11 @@ cp_convert_to_pointer (tree type, tree expr)
expr = build_int_cst_type (type, -1);
}
else
- expr = build_int_cst (type, 0);
+ {
+ if (!NULLPTR_TYPE_P (TREE_TYPE (expr)))
+ warning (0, "zero as null pointer constant");
+ expr = build_int_cst (type, 0);
+ }
return expr;
}