https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107801

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't think we want to build (parts of) the library with non-default options
like that. It might affect the ABI of the library, and all users would have to
use the same options for their own code.

I think we can just use bitset::size_type for the _M_bytes member. We don't
need to use uint32_t there if size_t only has 16 bits. We can't allocate that
much memory anyway.

--- a/libstdc++-v3/src/c++17/memory_resource.cc
+++ b/libstdc++-v3/src/c++17/memory_resource.cc
@@ -505,7 +505,7 @@ namespace pmr
     }

     // Allocated size of chunk:
-    uint32_t _M_bytes = 0;
+    bitset::size_type _M_bytes = 0;
     // Start of allocated chunk:
     std::byte* _M_p = nullptr;

@@ -579,7 +579,7 @@ namespace pmr
   // For 16-bit pointers it's five pointers (10 bytes).
   // TODO pad 64-bit to 4*sizeof(void*) to avoid splitting across cache lines?
   static_assert(sizeof(chunk)
-      == sizeof(bitset::size_type) + sizeof(uint32_t) + 2 * sizeof(void*));
+      == 2 * sizeof(bitset::size_type) + 2 * sizeof(void*));

   // An oversized allocation that doesn't fit in a pool.
   struct big_block





With that change, I get failures for fs_dir.cc instead:

libtool: compile:  /home/jwakely/src/gcc/build-h8/./gcc/xgcc -shared-libgcc
-B/home/jwakely/src/gcc/build-h8/./gcc -nostdinc++
-L/home/jwakely/src/gcc/build-h8/h8300-elf/normal/libstdc++-v3/src
-L/home/jwakely/src/gcc/build-h8/h8300-elf/normal/libstdc++-v3/src/.libs
-L/home/jwakely/src/gcc/build-h8/h8300-elf/normal/libstdc++-v3/libsupc++/.libs
-nostdinc -B/home/jwakely/src/gcc/build-h8/h8300-elf/normal/newlib/ -isystem
/home/jwakely/src/gcc/build-h8/h8300-elf/normal/newlib/targ-include -isystem
/home/jwakely/src/gcc/gcc/newlib/libc/include
-B/home/jwakely/gcc/h8300-elf/h8300-elf/bin/
-B/home/jwakely/gcc/h8300-elf/h8300-elf/lib/ -isystem
/home/jwakely/gcc/h8300-elf/h8300-elf/include -isystem
/home/jwakely/gcc/h8300-elf/h8300-elf/sys-include -mn
-I/home/jwakely/src/gcc/gcc/libstdc++-v3/../libgcc
-I/home/jwakely/src/gcc/build-h8/h8300-elf/normal/libstdc++-v3/include/h8300-elf
-I/home/jwakely/src/gcc/build-h8/h8300-elf/normal/libstdc++-v3/include
-I/home/jwakely/src/gcc/gcc/libstdc++-v3/libsupc++ -std=gnu++17 -nostdinc++
-fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2
-fdiagnostics-show-location=once -ffunction-sections -fdata-sections
-frandom-seed=fs_dir.lo -fimplicit-templates -g -O2 -c
/home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++17/fs_dir.cc -o fs_dir.o
In file included from
/home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++17/fs_dir.cc:37:
/home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++17/../filesystem/dir-common.h: In
static member function ‘static std::filesystem::__gnu_posix::DIR*
std::filesystem::_Dir_base::openat(const _At_path&, bool)’:
/home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++17/../filesystem/dir-common.h:210:36:
warning: unused parameter ‘nofollow’ [-Wunused-parameter]
  210 |   openat(const _At_path& atp, bool nofollow)
      |                               ~~~~~^~~~~~~~
/home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++17/fs_dir.cc: In member function
‘bool std::filesystem::__cxx11::_Dir::do_unlink(bool, std::error_code&) const’:
/home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++17/fs_dir.cc:147:18: warning:
unused parameter ‘is_directory’ [-Wunused-parameter]
  147 |   do_unlink(bool is_directory, error_code& ec) const noexcept
      |             ~~~~~^~~~~~~~~~~~
/tmp/ccsGgjxM.s: Assembler messages:
/tmp/ccsGgjxM.s:14980: Error: value of 000169ff too large for field of 2 bytes
at 00000010
/tmp/ccsGgjxM.s:14990: Error: value of 00025a7b too large for field of 2 bytes
at 0000002a
/tmp/ccsGgjxM.s:15018: Error: value of 0002e814 too large for field of 2 bytes
at 00000065
/tmp/ccsGgjxM.s:15024: Error: value of 0002e805 too large for field of 2 bytes
at 00000073
/tmp/ccsGgjxM.s:15033: Error: value of 00030c1c too large for field of 2 bytes
at 00000083
(and hundreds more assembler errors like that)

Reply via email to