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] |
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).
-- Marc Glisse
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |