[PATCH] IA-64/GAS: Fix format truncation compilation errors
Maciej W. Rozycki
macro@orcam.me.uk
Thu Aug 7 13:31:08 GMT 2025
On Thu, 7 Aug 2025, Jan Beulich wrote:
> > Fix compilation errors:
> >
> > .../gas/config/tc-ia64.c: In function 'declare_register_set':
> > .../gas/config/tc-ia64.c:5375:41: error: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size 8 [-Werror=format-truncation=]
> > 5375 | snprintf (name, sizeof (name), "%s%u", prefix, i);
> > | ^~
> > .../gas/config/tc-ia64.c:5375:38: note: directive argument in the range [0, 4294967294]
> > 5375 | snprintf (name, sizeof (name), "%s%u", prefix, i);
> > | ^~~~~~
> > .../gas/config/tc-ia64.c:5375:7: note: 'snprintf' output 2 or more bytes (assuming 11) into a destination of size 8
> > 5375 | snprintf (name, sizeof (name), "%s%u", prefix, i);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > observed with GCC 10. Pick 16 for a round 64-bit stack frame size.
>
> This looks to be a workaround for a compiler shortcoming, not really a fix
> for anything. declare_register_set() being static, the compiler can actually
> know value ranges as well as string literals passed in, and hence it could
> infer that no more than 6 bytes of the buffer would ever be used. Please can
> we call workarounds workarounds, not bug fixes?
There's no mention of a bug and the description merely states the facts
(that the change fixes compilation errors specifically with GCC 10) in a
neutral way. If you think that s/Fix/Work around/ will make the statement
acceptable though, then I'm not going to argue; I couldn't care less.
> In case you don't get a reply from Jim within, say, a week: Okay with
> respective adjustments to subject and description.
Thank you for your review.
Maciej
More information about the Binutils
mailing list