This is the mail archive of the gcc-patches@gcc.gnu.org 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: [C PATCH] Discard P - (P + CST) optimization in pointer_diff (PR c/61240)


On Mon, Aug 04, 2014 at 02:36:12PM +0200, Marc Glisse wrote:
> On Mon, 4 Aug 2014, Marek Polacek wrote:
> 
> >On Mon, Aug 04, 2014 at 12:51:06PM +0200, Richard Biener wrote:
> >>On Mon, 4 Aug 2014, Marc Glisse wrote:
> >>
> >>>On Mon, 4 Aug 2014, Marek Polacek wrote:
> >>>
> >>>>+/* { dg-do compile } */
> >>>>+
> >>>>+void
> >>>>+foo (void)
> >>>>+{
> >>>>+  volatile __PTRDIFF_TYPE__ t;
> >>>>+  int i;
> >>>>+  int *p = &i;
> >>>>+  int *q = &i + 1;
> >>>>+  t = q - (q - 1);
> >>>>+  t = (q - 1) - q; /* { dg-warning "integer overflow in expression" } */
> >>>>+  t = p - (p - 1);
> >>>>+  t = (p - 1) - p ; /* { dg-warning "integer overflow in expression" } */
> >>>>+}
> >>>
> >>>Why do you want a warning for (q - 1) - q ? It looks like a perfectly correct
> >>>way to say -1 to me (ptrdiff_t is a signed type for a reason).
> >
> >It's not that I want the warning there.  I can probably drop the two
> >lines from the test.
> 
> Well, no, I think we want those two lines, but to test that there is *no*
> warning. The bug is only halfway fixed if we still warn for (q-1)-q. But
> maybe you are trying to split the fix in 2 patches, in which case I don't
> really mind what the intermediate status is.
 
Yeah - I'd like to deal with reimplementing the optimization in fwprop
first.  The "(p - 1) - p" warning will need a different fix.

	Marek


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