https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85175
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- The warning appeared with r257857: r257857 | law | 2018-02-20 13:59:22 -0500 (Tue, 20 Feb 2018) | 8 lines PR middle-end/82123 PR tree-optimization/81592 PR middle-end/79257 * gimple-ssa-sprintf.c (format_integer): Query EVRP range analyzer for range data rather than using global data. The difference in the dump between the revision prior to it and r257857 is: Directive 2 at offset 2: "%d" Result: 1, 1, 11, 11 (3, 3, 13, 13) and Directive 2 at offset 2: "%d" Result: 1, 11, 11, 11 (3, 13, 13, 13) I.e., GCC now thinks the likely output of the %d directive is 11 bytes (the second number on the Result: line). Prior to r257857 the range type of the argument was VR_VARYING for which the warning doesn't trigger. With r257857 the range is [-2147483647, 3] of which the warning uses the larger bound to trigger. So with the change above GCC is doing a better but imperfect job of determining the range. Changing the variable to unsigned constrains the lower bound to zero and eliminates the warning even at -Os.