* [Bug c/61240] [4.8/4.9/4.10 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
@ 2014-05-20 8:38 ` rguenth at gcc dot gnu.org
2014-05-22 9:07 ` rguenth at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-20 8:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-05-20
Target Milestone|--- |4.8.3
Summary|Incorrect warning "integer |[4.8/4.9/4.10 Regression]
|overflow in expression" on |Incorrect warning "integer
|pointer-pointer subtraction |overflow in expression" on
| |pointer-pointer subtraction
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We warn for
<integer_cst 0x7ffff6d54e28 type <integer_type 0x7ffff6c407e0 long int>
constant public overflow 1>
via c-common.c:overflow_warning called from
#1 0x000000000065b80e in parser_build_binary_op (location=5653,
code=MINUS_EXPR, arg1=..., arg2=...)
at /space/rguenther/src/svn/trunk/gcc/c/c-typeck.c:3411
#2 0x000000000068f5ed in c_parser_binary_expression (parser=0x7ffff6d67000,
after=0x0, omp_atomic_lhs=<tree 0x0>)
at /space/rguenther/src/svn/trunk/gcc/c/c-parser.c:6282
#3 0x000000000068dfee in c_parser_conditional_expression (
parser=0x7ffff6d67000, after=0x0, omp_atomic_lhs=<tree 0x0>)
at /space/rguenther/src/svn/trunk/gcc/c/c-parser.c:5934
#4 0x000000000068dd75 in c_parser_expr_no_commas (parser=0x7ffff6d67000,
after=0x0, omp_atomic_lhs=<tree 0x0>)
at /space/rguenther/src/svn/trunk/gcc/c/c-parser.c:5852
when building p - (p + -1U) which gets simplified to - -1U -> 1U (with overflow
set - as it's sizetype arithmetic). pointer_diff is guilty here which calls
/* First do the subtraction as integers;
then drop through to build the divide operator.
Do not do default conversions on the minus operator
in case restype is a short type. */
op0 = build_binary_op (loc,
MINUS_EXPR, convert (inttype, op0),
convert (inttype, op1), 0);
doing 0 - -1U, converting them to inttype (long int) first. I suggest
to do that conversion and strip overflow bits in the POINTER_PLUS_EXPR
decomposition part.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/4.10 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
2014-05-20 8:38 ` [Bug c/61240] [4.8/4.9/4.10 Regression] " rguenth at gcc dot gnu.org
@ 2014-05-22 9:07 ` rguenth at gcc dot gnu.org
2014-07-01 20:09 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-22 9:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.3 |4.8.4
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 4.8.3 is being released, adjusting target milestone.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/4.10 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
2014-05-20 8:38 ` [Bug c/61240] [4.8/4.9/4.10 Regression] " rguenth at gcc dot gnu.org
2014-05-22 9:07 ` rguenth at gcc dot gnu.org
@ 2014-07-01 20:09 ` jakub at gcc dot gnu.org
2014-08-04 7:21 ` mpolacek at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-07-01 20:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r184965.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/4.10 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
` (2 preceding siblings ...)
2014-07-01 20:09 ` jakub at gcc dot gnu.org
@ 2014-08-04 7:21 ` mpolacek at gcc dot gnu.org
2014-08-04 7:30 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-08-04 7:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Maybe best would be to remove the optimization in pointer_diff altogether.
Mine for now.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/4.10 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
` (3 preceding siblings ...)
2014-08-04 7:21 ` mpolacek at gcc dot gnu.org
@ 2014-08-04 7:30 ` jakub at gcc dot gnu.org
2014-08-04 7:39 ` mpolacek at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-08-04 7:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
But in that case we should have an adequate replacement on the
match_and_simplify side.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/4.10 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
` (4 preceding siblings ...)
2014-08-04 7:30 ` jakub at gcc dot gnu.org
@ 2014-08-04 7:39 ` mpolacek at gcc dot gnu.org
2014-12-01 12:26 ` [Bug c/61240] [4.8/4.9/5 " rguenth at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-08-04 7:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
But C++ has its own pointer_diff version that doesn't do such optimization.
With my change the C FE would generate the same expr as the C++ FE. And FEs
shouldn't perform such optimizations anyway.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/5 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
` (5 preceding siblings ...)
2014-08-04 7:39 ` mpolacek at gcc dot gnu.org
@ 2014-12-01 12:26 ` rguenth at gcc dot gnu.org
2014-12-01 12:35 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-12-01 12:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic,
| |missed-optimization
Priority|P3 |P2
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
So this is also a missed optimization on the C++ side? Btw, the C++ FE warns
for me as well (on trunk).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/5 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
` (6 preceding siblings ...)
2014-12-01 12:26 ` [Bug c/61240] [4.8/4.9/5 " rguenth at gcc dot gnu.org
@ 2014-12-01 12:35 ` mpolacek at gcc dot gnu.org
2014-12-19 13:28 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-12-01 12:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I view this as a problem that we fold too early - I think this bug (and its
kin) are to be solved with delayed folding.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/5 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
` (7 preceding siblings ...)
2014-12-01 12:35 ` mpolacek at gcc dot gnu.org
@ 2014-12-19 13:28 ` jakub at gcc dot gnu.org
2015-02-13 8:45 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-19 13:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.4 |4.8.5
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.4 has been released.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/5 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
` (8 preceding siblings ...)
2014-12-19 13:28 ` jakub at gcc dot gnu.org
@ 2015-02-13 8:45 ` mpolacek at gcc dot gnu.org
2015-04-27 17:54 ` [Bug c/61240] [4.8/4.9/5/6 " ktietz at gcc dot gnu.org
2015-06-30 22:49 ` [Bug c/61240] [4.9/5/6 " divyajyotidas15 at gmail dot com
11 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-02-13 8:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.5 |6.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.8/4.9/5/6 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
` (9 preceding siblings ...)
2015-02-13 8:45 ` mpolacek at gcc dot gnu.org
@ 2015-04-27 17:54 ` ktietz at gcc dot gnu.org
2015-06-30 22:49 ` [Bug c/61240] [4.9/5/6 " divyajyotidas15 at gmail dot com
11 siblings, 0 replies; 13+ messages in thread
From: ktietz at gcc dot gnu.org @ 2015-04-27 17:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Kai Tietz <ktietz at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ktietz at gcc dot gnu.org
--- Comment #11 from Kai Tietz <ktietz at gcc dot gnu.org> ---
Issue is fixed for C++ delayed folding.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/61240] [4.9/5/6 Regression] Incorrect warning "integer overflow in expression" on pointer-pointer subtraction
2014-05-19 23:10 [Bug c/61240] New: Incorrect warning "integer overflow in expression" on pointer-pointer subtraction Keith.S.Thompson at gmail dot com
` (10 preceding siblings ...)
2015-04-27 17:54 ` [Bug c/61240] [4.8/4.9/5/6 " ktietz at gcc dot gnu.org
@ 2015-06-30 22:49 ` divyajyotidas15 at gmail dot com
11 siblings, 0 replies; 13+ messages in thread
From: divyajyotidas15 at gmail dot com @ 2015-06-30 22:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61240
Divya Jyoti Das <divyajyotidas15 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |divyajyotidas15 at gmail dot com
--- Comment #12 from Divya Jyoti Das <divyajyotidas15 at gmail dot com> ---
(In reply to Marek Polacek from comment #7)
> But C++ has its own pointer_diff version that doesn't do such optimization.
> With my change the C FE would generate the same expr as the C++ FE. And FEs
> shouldn't perform such optimizations anyway.
^ permalink raw reply [flat|nested] 13+ messages in thread