]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix some algos for 16-bit size_t [PR108221]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 9 Jan 2023 10:45:31 +0000 (10:45 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 10 Jan 2023 10:09:21 +0000 (10:09 +0000)
commit769fae76dfd71045fe062e7b1edef0f59e50371d
tree0a4e4956a77b42b8093ec509854130f74f538bab
parentb39f4333d18cc58b1a655c537a78fefe95b82609
libstdc++: Fix some algos for 16-bit size_t [PR108221]

Some standard algorithms fail to compile when size_t or ptrdiff_t is
narrower than int. The __lg helper function is ambiguous if ptrdiff_t is
short or __int20, so replace it with a function template that works for
those types as well as signed/unsigned int/long/long long. The helpers
for stable_sort perform arithmetic on size values and assume the types
won't change, which isn't true if the type promotes to int.

libstdc++-v3/ChangeLog:

PR libstdc++/108221
* include/bits/stl_algobase.h (__lg): Replace six overloads with
a single function template for all integer types.
* include/bits/stl_algo.h (__merge_adaptive_resize): Cast
arithmetic results back to _Distance.
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/include/bits/stl_algobase.h
This page took 0.058131 seconds and 5 git commands to generate.