]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix <charconv> uses of signed types with <bit> functions
authorJonathan Wakely <jwakely@redhat.com>
Tue, 14 Nov 2023 10:56:57 +0000 (10:56 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 18 Mar 2024 11:01:42 +0000 (11:01 +0000)
commitac0cf0786bb3da60f412afe800fd385686b9517d
tree37baaf7f3a0f83e78712e28658fb285eeac3bdea
parent80e88183d47ca4d7c8441355f736fc918d7d05dc
libstdc++: Fix <charconv> uses of signed types with <bit> functions

In <charconv> we pass the int __base parameter to our internal versions
of <bit> functions, __bit_width and __countr_zero. Those functions are
only defined for unsigned types, so we need to convert the base to
unsigned. The base must be in the range [2,36] so we can mask off the
low bits and then convert that to unsigned, so that we don't need to
care about negative values becoming large unsigned values.

libstdc++-v3/ChangeLog:

* include/std/charconv (__from_chars_pow2_base): Convert base to
unsigned for call to __countr_zero.
(__from_chars_alnum): Likewise for call to __bit_width.

(cherry picked from commit 1c15303375f7089ff985b085ab877b11ebfbc4b7)
libstdc++-v3/include/std/charconv