Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-05-31 Thread Jason Merrill
On Tue, May 31, 2016 at 1:18 PM, Martin Sebor wrote: > On 03/31/2016 11:54 AM, Jason Merrill wrote: >> >> OK, thanks. > > This bug was fixed in 6.1 but it is also a GCC 5 regression and > the patch hasn't been applied there yet. Should I go ahead and > backport it to the 5.x branch? It seems saf

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-05-31 Thread Martin Sebor
On 03/31/2016 11:54 AM, Jason Merrill wrote: OK, thanks. This bug was fixed in 6.1 but it is also a GCC 5 regression and the patch hasn't been applied there yet. Should I go ahead and backport it to the 5.x branch? Martin

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-31 Thread Jason Merrill
OK, thanks. Jason

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-31 Thread Martin Sebor
+ /* Avoid folding references to struct members at offset 0 to + prevent tests like '&ptr->firstmember == 0' from getting + eliminated. When ptr is null, although the -> expression + is strictly speaking invalid, GCC retains it as a matter + of QoI.

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-31 Thread Jeff Law
On 03/30/2016 01:25 PM, Jason Merrill wrote: On 03/30/2016 12:32 PM, Martin Sebor wrote: On 03/30/2016 09:30 AM, Jason Merrill wrote: On 03/29/2016 11:57 PM, Martin Sebor wrote: Are we confident that arr[0] won't make it here as POINTER_PLUS_EXPR or some such? I'm as confident as I can be gi

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-30 Thread Jason Merrill
On 03/30/2016 06:50 PM, Martin Sebor wrote: On 03/30/2016 01:25 PM, Jason Merrill wrote: On 03/30/2016 12:32 PM, Martin Sebor wrote: On 03/30/2016 09:30 AM, Jason Merrill wrote: On 03/29/2016 11:57 PM, Martin Sebor wrote: Are we confident that arr[0] won't make it here as POINTER_PLUS_EXPR or

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-30 Thread Martin Sebor
On 03/30/2016 01:25 PM, Jason Merrill wrote: On 03/30/2016 12:32 PM, Martin Sebor wrote: On 03/30/2016 09:30 AM, Jason Merrill wrote: On 03/29/2016 11:57 PM, Martin Sebor wrote: Are we confident that arr[0] won't make it here as POINTER_PLUS_EXPR or some such? I'm as confident as I can be gi

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-30 Thread Jason Merrill
On 03/30/2016 12:32 PM, Martin Sebor wrote: On 03/30/2016 09:30 AM, Jason Merrill wrote: On 03/29/2016 11:57 PM, Martin Sebor wrote: Are we confident that arr[0] won't make it here as POINTER_PLUS_EXPR or some such? I'm as confident as I can be given that this is my first time working in this

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-30 Thread Martin Sebor
On 03/30/2016 09:30 AM, Jason Merrill wrote: On 03/29/2016 11:57 PM, Martin Sebor wrote: Are we confident that arr[0] won't make it here as POINTER_PLUS_EXPR or some such? I'm as confident as I can be given that this is my first time working in this area. Which piece of code or what assumptio

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-30 Thread Jason Merrill
On 03/29/2016 11:57 PM, Martin Sebor wrote: Are we confident that arr[0] won't make it here as POINTER_PLUS_EXPR or some such? I'm as confident as I can be given that this is my first time working in this area. Which piece of code or what assumption in particular are you concerned about? I w

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-29 Thread Martin Sebor
On 03/29/2016 12:54 PM, Jason Merrill wrote: On 03/28/2016 06:04 PM, Martin Sebor wrote: + && compare_tree_int (arg1, 0) == 0) This can be integer_zerop. Sure. +case GE_EXPR: +case EQ_EXPR: +case LE_EXPR: + return boolean_false_node; +ca

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-29 Thread Jason Merrill
On 03/28/2016 06:04 PM, Martin Sebor wrote: + && compare_tree_int (arg1, 0) == 0) This can be integer_zerop. + case GE_EXPR: + case EQ_EXPR: + case LE_EXPR: + return boolean_false_node; + case GT_EXPR: + case LT_EXPR:

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-28 Thread Martin Sebor
I think let's defer the fix for c++/60760 (i.e. the nullptr_p bits) until stage 1, when it can be combined with the POINTER_PLUS_EXPR fix, and put the rest of this patch in now. I can split up the patch into two and post the subset without the fix for c++/60760, though I don't expect to be done

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-23 Thread Jason Merrill
On 03/22/2016 04:01 PM, Martin Sebor wrote: On 03/22/2016 12:52 PM, Jason Merrill wrote: On 03/21/2016 06:09 PM, Jeff Law wrote: On 03/21/2016 11:54 AM, Jason Merrill wrote: Both b0 and b1 are invalid and should be diagnosed, but only b1 is. b1 isn't because because by the time we see its ini

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-22 Thread Martin Sebor
On 03/22/2016 12:52 PM, Jason Merrill wrote: On 03/21/2016 06:09 PM, Jeff Law wrote: On 03/21/2016 11:54 AM, Jason Merrill wrote: Both b0 and b1 are invalid and should be diagnosed, but only b1 is. b1 isn't because because by the time we see its initializer in constexpr.c it's been transformed

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-22 Thread Jason Merrill
On 03/21/2016 06:09 PM, Jeff Law wrote: On 03/21/2016 11:54 AM, Jason Merrill wrote: Both b0 and b1 are invalid and should be diagnosed, but only b1 is. b1 isn't because because by the time we see its initializer in constexpr.c it's been transformed into the equivalent of "b1 = (int*)ps" (thoug

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-21 Thread Jeff Law
On 03/21/2016 11:54 AM, Jason Merrill wrote: Both b0 and b1 are invalid and should be diagnosed, but only b1 is. b1 isn't because because by the time we see its initializer in constexpr.c it's been transformed into the equivalent of "b1 = (int*)ps" (though we don't see the cast which would also

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-21 Thread Jason Merrill
On 03/18/2016 01:04 PM, Jeff Law wrote: On 03/17/2016 03:16 PM, Martin Sebor wrote: The difficulty I've run into with detecting these problems in later phases is that some invalid expressions have already been simplified by the front end. The example that applies here (even though this is still

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-20 Thread Jeff Law
On 03/14/2016 03:25 PM, Martin Sebor wrote: The attached patch fixes the outstanding cases mentioned in comment 10 on bug c++/67376. While testing the fix I uncovered a number of other related problems without which the test would have been incomplete. They include: PR c++/70170 - [6 regressio

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-20 Thread Martin Sebor
static tree cxx_eval_constant_expression (const constexpr_ctx *, tree, - bool, bool *, bool *, tree * = NULL); + bool, bool *, bool *, bool * = NULL, + tree * = NULL); I didn't look deeply, but do you end up fixi

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-19 Thread Jeff Law
On 03/14/2016 04:13 PM, Jakub Jelinek wrote: On Mon, Mar 14, 2016 at 03:25:07PM -0600, Martin Sebor wrote: PR c++/67376 - [5/6 regression] Comparison with pointer to past-the-end of array fails inside constant expression PR c++/70170 - [6 regression] bogus not a constant expression error

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-19 Thread Jeff Law
On 03/17/2016 03:16 PM, Martin Sebor wrote: gcc-67376.patch PR c++/67376 - [5/6 regression] Comparison with pointer to past-the-end of array fails inside constant expression PR c++/70170 - [6 regression] bogus not a constant expression error comparing pointer to array to null

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-19 Thread Jeff Law
On 03/17/2016 03:16 PM, Martin Sebor wrote: static tree cxx_eval_constant_expression (const constexpr_ctx *, tree, - bool, bool *, bool *, tree * = NULL); + bool, bool *, bool *, bool * = NULL, + tree * = NULL);

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-19 Thread Jakub Jelinek
On Wed, Mar 16, 2016 at 01:38:21PM -0600, Jeff Law wrote: > On 03/14/2016 04:13 PM, Jakub Jelinek wrote: > >On Mon, Mar 14, 2016 at 03:25:07PM -0600, Martin Sebor wrote: > >>PR c++/67376 - [5/6 regression] Comparison with pointer to past-the-end > >>of array fails inside constant expression > >

Re: [PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-14 Thread Jakub Jelinek
On Mon, Mar 14, 2016 at 03:25:07PM -0600, Martin Sebor wrote: > PR c++/67376 - [5/6 regression] Comparison with pointer to past-the-end > of array fails inside constant expression > PR c++/70170 - [6 regression] bogus not a constant expression error comparing > pointer to array to null

[PATCH] c++/67376 Comparison with pointer to past-the-end, of array fails inside constant expression

2016-03-14 Thread Martin Sebor
The attached patch fixes the outstanding cases mentioned in comment 10 on bug c++/67376. While testing the fix I uncovered a number of other related problems without which the test would have been incomplete. They include: PR c++/70170 - [6 regression] bogus not a constant expression error