This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] c++/60760 - arithmetic on null pointers should not be allowed in constant expressions
- From: Jason Merrill <jason at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 24 Jun 2016 00:36:21 +0300
- Subject: Re: [PATCH] c++/60760 - arithmetic on null pointers should not be allowed in constant expressions
- Authentication-results: sourceware.org; auth=none
- References: <573504DD dot 9040707 at gmail dot com> <aed14825-8dd6-9817-3efa-ff963e62aa5f at redhat dot com> <574E0A41 dot 9070204 at gmail dot com> <d3a3974a-26bf-e470-48c9-c3d9bbd727e6 at redhat dot com> <574F2CF7 dot 1000800 at gmail dot com> <cb44c3da-4a8b-302b-7902-fc6e92f40906 at redhat dot com> <57684132 dot 8010303 at gmail dot com>
On 06/20/2016 10:17 PM, Martin Sebor wrote:
+ && tree_int_cst_equal (lhs, null_pointer_node)
+ && !tree_int_cst_equal (rhs, integer_zero_node))
Not integer_zerop?
+ "invalid conversion involving a null pointer");
...
+ "invalid conversion from %qT to %qT",
The conversion isn't invalid, it just isn't a constant expression. For
the null pointer to pointer conversion, does this properly allow
conversion to void* or to base*?
+ if (integer_zerop (op))
...
+ else if (!integer_zerop (op))
The second test seems redundant.
Jason