https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81876
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2017-08-17 00:00:00 |2017-12-5 Summary|[7/8 Regression] bogus |[7 Regression] bogus |-Wstrict-overflow warning |-Wstrict-overflow warning |with -O3 |with -O3 --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- The warning no longer occurs on trunk, re-confirmed on the branch. I think there's two sides generally 1) the strict-overflow warnings out of middle-end folding code are just too fragile, we're getting rid of them 2) the question is what location stmts should have for code generated by GCC (like that stmts to compute the memset size). We currently assign a location near the emission place but one could argue it should be UNKNOWN_LOCATION (or ARTIFICIAL_LOCATION if there would be sth like this). We'd then simply avoid emitting warnings with no good location, aka treating the stmts as artificial (compiler-generated). Index: gcc/tree-loop-distribution.c =================================================================== --- gcc/tree-loop-distribution.c (revision 255402) +++ gcc/tree-loop-distribution.c (working copy) @@ -813,7 +813,7 @@ generate_memset_builtin (struct loop *lo /* The new statements will be placed before LOOP. */ gsi = gsi_last_bb (loop_preheader_edge (loop)->src); - nb_bytes = build_size_arg_loc (loc, partition->main_dr, partition->niter, + nb_bytes = build_size_arg_loc (UNKNOWN_LOCATION, partition->main_dr, partition->niter, partition->plus_one); nb_bytes = force_gimple_operand_gsi (&gsi, nb_bytes, true, NULL_TREE, false, GSI_CONTINUE_LINKING); changes the warning to > ./cc1 -quiet t.c -O3 -Wall -Wstrict-overflow t.c: In function ‘cell_array_lower’: cc1: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow] which shows we also need sth to prune such useless warnings: Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 255402) +++ gcc/fold-const.c (working copy) @@ -265,7 +265,8 @@ fold_undefer_overflow_warnings (bool iss locus = input_location; else locus = gimple_location (stmt); - warning_at (locus, OPT_Wstrict_overflow, "%s", warnmsg); + if (locus != UNKNOWN_LOCATION) + warning_at (locus, OPT_Wstrict_overflow, "%s", warnmsg); } /* Stop deferring overflow warnings, ignoring any deferred another side-effect might be that we avoid some jumping in gdb if we don't assign line info to this kind of stmts.