https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78959
--- Comment #6 from John David Anglin <danglin at gcc dot gnu.org> --- (In reply to Martin Sebor from comment #1) > The test output > > "4105" => 4 > > indicates that on HP-UX the %hhd directive doesn't convert the int argument > (4105) to unsigned char to end up with 9 as the test expects. I think > that's a bug in the HP-UX sprintf (do you have a way of reporting it and/or > finding out if HP will fix it?), although there is/was some uncertainty > about whether passing a value outside the range of char to %hhd is valid > (https://groups.google.com/forum/#!topic/comp.std.c/evMVFdOufys). snprintf returns a count of 4 and buf contains "4105". So, it looks like on HP-UX 11.11 %hhd is being interpreted as %hd (a short integer conversion). The %hhd form is not described in the 11.11 man page.