This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] c++/60760 - arithmetic on null pointers should not be allowed in constant expressions

Ping.  Jason, do you have any further comments or concerns with
the updated patch?


On 07/06/2016 04:20 PM, Martin Sebor wrote:
On 06/23/2016 03:36 PM, Jason Merrill wrote:
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.

(Sorry for the delay following up on this review.  I got busy
with something else.)

I've adjusted the text of the diagnostics, though the first one
is also issued for conversions that are invalid even outside
constexpr, such as those that cast away constness, or those that
cast to incomplete type.  Without -fpermissve those are already
diagnosed by this point but I'm not sure how much trouble to go
to here to avoid diagnosing them again, or at all with

the null pointer to pointer conversion, does this properly allow
conversion to void* or to base*?

It didn't handle either but does now.  Thank you for calling it
out.  Surprisingly, a regression run including libstdc++ didn't
catch it.  I've added tests to exercise it.

+        if (integer_zerop (op))
+         else if (!integer_zerop (op))

The second test seems redundant.

I have removed it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]