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

2016-08-02 Thread Martin Sebor
On 08/02/2016 12:34 AM, Thomas Schwinge wrote: Hi! On Wed, 6 Jul 2016 16:20:44 -0600, Martin Sebor wrote: PR c++/60760 - arithmetic on null pointers should not be allowed in constant expressions PR c++/71091 - constexpr reference bound to a null pointer dereference

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

2016-08-02 Thread Thomas Schwinge
Hi! On Wed, 6 Jul 2016 16:20:44 -0600, Martin Sebor wrote: > PR c++/60760 - arithmetic on null pointers should not be allowed in constant > expressions > PR c++/71091 - constexpr reference bound to a null pointer dereference >accepted > > [...] > *

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

2016-07-20 Thread Jason Merrill
On Wed, Jul 20, 2016 at 2:15 PM, Martin Sebor wrote: > On 07/20/2016 07:52 AM, Jason Merrill wrote: >> >> On Mon, Jul 18, 2016 at 6:15 PM, Martin Sebor wrote: >>> >>> On 07/18/2016 11:51 AM, Jason Merrill wrote: On 07/06/2016 06:20 PM, Martin

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

2016-07-20 Thread Martin Sebor
On 07/20/2016 07:52 AM, Jason Merrill wrote: On Mon, Jul 18, 2016 at 6:15 PM, Martin Sebor wrote: On 07/18/2016 11:51 AM, Jason Merrill wrote: On 07/06/2016 06:20 PM, Martin Sebor wrote: @@ -2911,6 +2923,14 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t,

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

2016-07-20 Thread Jason Merrill
On Mon, Jul 18, 2016 at 6:15 PM, Martin Sebor wrote: > On 07/18/2016 11:51 AM, Jason Merrill wrote: >> >> On 07/06/2016 06:20 PM, Martin Sebor wrote: >>> >>> @@ -2911,6 +2923,14 @@ cxx_eval_indirect_ref (const constexpr_ctx >>> *ctx, tree t, >>>if (*non_constant_p) >>>

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

2016-07-18 Thread Martin Sebor
On 07/18/2016 11:51 AM, Jason Merrill wrote: On 07/06/2016 06:20 PM, Martin Sebor wrote: @@ -2911,6 +2923,14 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, if (*non_constant_p) return t; + if (integer_zerop (op0)) +{ + if (!ctx->quiet)

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

2016-07-18 Thread Jason Merrill
On 07/06/2016 06:20 PM, Martin Sebor wrote: @@ -2911,6 +2923,14 @@ cxx_eval_indirect_ref (const constexpr_ctx *ctx, tree t, if (*non_constant_p) return t; + if (integer_zerop (op0)) + { + if (!ctx->quiet) + error ("dereferencing a

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

2016-07-14 Thread Martin Sebor
Ping. Jason, do you have any further comments or concerns with the updated patch? https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00280.html Thanks Martin 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: +

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

2016-07-06 Thread Martin Sebor
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"); ... +

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

2016-06-23 Thread Jason Merrill
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

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

2016-06-20 Thread Martin Sebor
+ if (TREE_CODE (whole) == INDIRECT_REF + && integer_zerop (TREE_OPERAND (whole, 0)) + && !ctx->quiet) +error ("dereferencing a null pointer in %qE", orig_whole); + if (TREE_CODE (t) == INTEGER_CST + && TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE + &&

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

2016-06-02 Thread Jason Merrill
On 06/01/2016 10:49 PM, Martin Sebor wrote: On 06/01/2016 01:20 PM, Jason Merrill wrote: On 06/01/2016 02:44 PM, Martin Sebor wrote: The new code in cxx_eval_component_reference diagnoses the following problem that's not detected otherwise: struct S { const S *s; }; constexpr S s = { 0

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

2016-06-01 Thread Martin Sebor
On 06/01/2016 01:20 PM, Jason Merrill wrote: On 06/01/2016 02:44 PM, Martin Sebor wrote: The new code in cxx_eval_component_reference diagnoses the following problem that's not detected otherwise: struct S { const S *s; }; constexpr S s = { 0 }; constexpr const void *p = >s; Note

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

2016-06-01 Thread Jason Merrill
On 06/01/2016 02:44 PM, Martin Sebor wrote: The new code in cxx_eval_component_reference diagnoses the following problem that's not detected otherwise: struct S { const S *s; }; constexpr S s = { 0 }; constexpr const void *p = >s; Note that this falls under core issue 1530, which has

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

2016-06-01 Thread Martin Sebor
The new code in cxx_eval_component_reference diagnoses the following problem that's not detected otherwise: struct S { const S *s; }; constexpr S s = { 0 }; constexpr const void *p = >s; Note that this falls under core issue 1530, which has not been resolved. I don't quite see the

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

2016-06-01 Thread Jason Merrill
On 05/31/2016 06:03 PM, Martin Sebor wrote: On 05/17/2016 01:44 PM, Jason Merrill wrote: On 05/12/2016 06:34 PM, Martin Sebor wrote: Attached is a resubmission of the patch for c++/60760 originally submitted late in the 6.0 cycle along with a patch for c++/67376. Since c++/60760 was not a

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

2016-05-31 Thread Martin Sebor
On 05/17/2016 01:44 PM, Jason Merrill wrote: On 05/12/2016 06:34 PM, Martin Sebor wrote: Attached is a resubmission of the patch for c++/60760 originally submitted late in the 6.0 cycle along with a patch for c++/67376. Since c++/60760 was not a regression, it was decided that it would be safer

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

2016-05-17 Thread Jason Merrill
On 05/12/2016 06:34 PM, Martin Sebor wrote: Attached is a resubmission of the patch for c++/60760 originally submitted late in the 6.0 cycle along with a patch for c++/67376. Since c++/60760 was not a regression, it was decided that it would be safer to defer the fix until after the 6.1.0

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

2016-05-12 Thread Martin Sebor
Attached is a resubmission of the patch for c++/60760 originally submitted late in the 6.0 cycle along with a patch for c++/67376. Since c++/60760 was not a regression, it was decided that it would be safer to defer the fix until after the 6.1.0 release. While retesting this patch I was happy to