[libcxx-commits] [libcxx] [libc++][string] Fix unnecessary padding for basic_string's __short (PR #135973)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 17 10:09:19 PDT 2025


philnik777 wrote:

> Also, when I put an empty struct into another struct, it still increment the size and has it's own address: https://godbolt.org/z/dYovsM71b . (Or I don't really get what you mean by datasize there. I assumed  "as a member of other struct". I would be grateful if you could point me to an explanation if I am wrong.)

Sorry, I didn't see this before. The datasize is a bit more complicated than that. You need to use `[[no_unique_address]]` or the EBO to make use of the fact that the datasize is sometimes smaller than the sozeof the struct.

I guess you're using a proprietary compiler with libc++? Just FYI, that's not officially supported. What I think is going on is that your compiler doesn't support `[[no_unique_address]]` for some reason and that's causing the size change. I would recommend compiling with warnings in system headers enabled and check whether there are any warnings about that. If that's the case you can't upgrade libc++ until the attribute is supported, since we rely on the attribute in a lot of places now.

https://github.com/llvm/llvm-project/pull/135973


More information about the libcxx-commits mailing list