On Thu, Feb 02, 2017 at 12:59:11PM -0700, Martin Sebor wrote: > > > - T (2, "%#hho", a); /* { dg-warning "nul past the end" } */ > > > - T (2, "%#hhx", a); /* { dg-warning ".%#hhx. directive > > > writing between 3 and . bytes into a region of size 2" } */ > > > + T (2, "%#hho", a); > > > + T (2, "%#hhx", a); > > On reflection, this isn't quite the right fix. We want to both set > the correct range and warn because the call will likely overflow. > This is an example of why the likely/unlikely counters have been > introduced. By setting min = 1 and likely = 2 for the %#hho and > 3 for the %#hhx we get the desired result.
Then please first define what should likely mean and document that. That is unrelated to the patch, both in the current trunk, with your patch as well as with my patch there is just res.range.likely = res.knownrange ? res.range.max : res.range.min; res.range.unlikely = res.range.max; for these cases. Do you want likely 2 because that the shortest length for more than one value (only a single value has the shortest length)? Something else? Jakub