aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-02-12 18:50:16 +0100
committerJakub Jelinek <jakub@redhat.com>2024-02-12 18:50:16 +0100
commit53bb7145135c0c9fe7f9735231befe2c7cba2708 (patch)
tree1e456d7de124b48ab8ae27aa7d4fcde0bcdda279 /gcc
parent160f3f31fe106741b7c95b3663e6794e6abc7fd8 (diff)
downloadgcc-53bb7145135c0c9fe7f9735231befe2c7cba2708.zip
gcc-53bb7145135c0c9fe7f9735231befe2c7cba2708.tar.gz
gcc-53bb7145135c0c9fe7f9735231befe2c7cba2708.tar.bz2
libiberty: Fix up libiberty_vprintf_buffer_size
When writing the HOST_SIZE_T_PRINT_UNSIGNED incremental patch, my first bootstrap failed on i686-linux. That is because I've also had @@ -1344,8 +1344,10 @@ adjust_field_rtx_def (type_p t, options_ } subfields = create_field (subfields, t, - xasprintf (".fld[%lu].%s", - (unsigned long) aindex, + xasprintf (".fld[" + HOST_SIZE_T_PRINT_UNSIGNED + "].%s", + (fmt_size_t) aindex, subname)); subfields->opt = nodot; if (t == note_union_tp) hunk in gengtype.cc. While sprintf obviously can print in this case %llu with fmt_size_t being unsigned long long (that is another bug I'll fix incrementally), seems libiberty_vprintf_buffer_size can't deal with that, it ignores h, hh, l, ll and L modifiers and unconditionally, estimates 30 chars as upper bounds for integers (that is fine) and then uses (void) va_arg (ap, int); to skip over the argument regardless if it was %d, %ld, %lld, %hd, %hhd etc. Now, on x86_64 that happens to work fine probably for all of those, on ia32 for everything but %lld, because it then skips just one half of the long long argument; now as there is %s after it, it will try to compute strlen not from the pointer argument corresponding to %s, but from the most significant half of the previous long long argument. So, the following patch attempts not to completely ignore the modifiers, but figure out from them whether to va_arg an int (used for h and hh as well), or long, or long long, or size_t, or ptrdiff_t - added support for z and t there, plus for Windows I64. And also %Lf etc. for long double. 2024-02-12 Jakub Jelinek <jakub@redhat.com> * vprintf-support.c (libiberty_vprintf_buffer_size): Handle properly l, ll, z, t or on _WIN32 I64 modifiers for diouxX and L modifier for fFgGeE.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions