This simplifies the string structs a bit more and the normal layout should not contain any undefined behaviour anymore. I don't think there is a way to achieve this in the alternate string mode without breaking the ABI.
Details
- Reviewers
ldionne Mordante var-const - Group Reviewers
Restricted Project - Commits
- rG5d55ffe94dc9: [libc++] Simplify the string structures a bit more
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Other than my comment, LGTM.
libcxx/include/string | ||
---|---|---|
738–741 | Here and above, we assume that 7+1 == 8 == CHAR_BIT, since the padding could potentially be wrong if that were not the case. I think this is a pre-existing condition, but I would suggest asserting it. Basically, I think our implementation doesn't support systems where CHAR_BIT != 8. WDYT? |
libcxx/include/string | ||
---|---|---|
740 | Is it really okay if the expression evaluates to zero? |
libcxx/include/string | ||
---|---|---|
740 | Clang and GCC allow arrays with zero size. https://godbolt.org/z/ddPMThYMz |
Note that this broke the LLDB data formatters.
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/lastFailedBuild/
I put up a patch to adapt them in https://reviews.llvm.org/D126080.
Chrome is observing failures on Windows caused by this patch: https://crbug.com/1334441
libcxx/include/string | ||
---|---|---|
695 | When you fix this can you add an static_assert that validates the size of the struct? |
I will note this patch fixes an ABI break on AIX caused by https://reviews.llvm.org/D123580.
Do you want to tell me that using size_type is correct for AIX and unsigned char is correct for Windows?
No, I was pointing out that a plain revert would be problematic. If the proposal is to change the type of the bit-fields to unsigned char, then that should be compatible on AIX as well.
When you fix this can you add an static_assert that validates the size of the struct?