]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix pool resource build errors for H8 [PR107801]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 22 Nov 2022 09:53:36 +0000 (09:53 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 22 Nov 2022 10:48:13 +0000 (10:48 +0000)
The array of pool sizes was previously adjusted to work for msp430-elf
which has 16-bit int and either 16-bit size_t or 20-bit size_t. The
largest pool sizes were disabled unless size_t has more than 20 bits.

The H8 family has 16-bit int but 32-bit size_t, which means that the
largest sizes are enabled, but 1<<15 produces a negative number that
then cannot be narrowed to size_t.

Replace the test for 32-bit size_t with a test for 32-bit int, which
means we won't use the 4kiB to 4MiB pools for targets with 16-bit int
even if they have a wider size_t.

libstdc++-v3/ChangeLog:

PR libstdc++/107801
* src/c++17/memory_resource.cc (pool_sizes): Disable large pools
for targets with 16-bit int.

(cherry picked from commit 0f9659e770304d3c44cfa0e793833a461bc487aa)

libstdc++-v3/src/c++17/memory_resource.cc

index bb6334c96947d6d3a3c5d69890c4f6f9479f01f5..d6555aa8823640b5aac9d859bb62c531703bcc54 100644 (file)
@@ -874,9 +874,11 @@ namespace pmr
       256, 320, 384, 448,
       512, 768,
 #if __SIZE_WIDTH__ > 16
+      // Use bigger pools if size_t has at least 20 bits.
       1024, 1536,
       2048, 3072,
-#if __SIZE_WIDTH__ > 20
+#if __INT_WIDTH__ >= 32
+      // Use even bigger pools if int has at least 32 bits.
       1<<12, 1<<13, 1<<14,
       1<<15, 1<<16, 1<<17,
       1<<20, 1<<21, 1<<22 // 4MB should be enough for anybody