Disable _LIBCPP_DEBUG_ASSERT and debug iterators in <string> during constant evaluation
Details
- Reviewers
• Quuxplusone ldionne - Group Reviewers
Restricted Project - Commits
- rG5675b6112aa9: [libc++] Disable _LIBCPP_DEBUG_ASSERT during constant evaluation
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/include/__debug | ||
---|---|---|
37 | This feels like a change in meaning, from "Assert in debug mode" to "Assert specifically concerned with debug iterators." It turns out that this macro has pretty much always been used with the latter meaning, though, so even though a better name might be _LIBCPP_DEBUG_ITERATOR_ASSERT, I think this is fine. However, the one place in libc++ that doesn't use the macro with the latter meaning, needs to be updated to use _LIBCPP_ASSERT instead. ../libcxx/include/bit: _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil"); I think this should just be _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil"); and if that's not right then investigation is needed as to why that's not right. Then, please update the summary/commit-message to talk about the semantic change here, which I think is more important than the <string> part. Something like, "_LIBCPP_DEBUG_ASSERT is now used strictly for debug iterators, and disabled during constant evaluation." Observe that this is a change for both <__hash_table> (since ages ago) and <string> (since D115765). | |
libcxx/include/string | ||
828–832 | Somewhere in the past year I'd suggested something like _LIBCPP_IF_DEBUG_ITERATORS( __get_db()->__insert_c(this); ) which could simplify this repeated pattern. Thoughts on reviving that idea? | |
2990 | Stray blank line here |
libcxx/include/__debug | ||
---|---|---|
37 | There are not that many usages of _LIBCPP_DEBUG_ASSERT. Maybe it would be good to change the meaning and rename it to _LIBCPP_DEBUG_ITERATOR_ASSERT in another patch? | |
libcxx/include/string | ||
828–832 | I do quite like the idea of _LIBCPP_IF_DEBUG_ITERATORS. Should I make this a more general patch to simplify the debug iterators across the repo, or would that be too much? |
libcxx/include/__debug | ||
---|---|---|
37 | IMO this is fine, but needs to be called out in the commit message. Basically, the important thing this patch is doing is that we're not going to check debug-only assertions inside constant expressions anymore. I think that's acceptable, since those assertions are meant to catch things like UB, and the compiler will do that for us during constexpr evaluation. | |
libcxx/include/string | ||
828–832 | I am leery of adding a bunch of macros as "shortcuts" for these things. I think the current approach is fine. | |
3497 | After your patch, this is a mix of 4 space and 2 space indentation. Please consistently use 4 space in this file, since that's what is done for the other functions in that file. This applies to all the other functions you touched AFAICT. |
Why have non-libc++ builds been triggered? Can I land with them failing? They don't seem to fail because of this patch.
I don't know. @goncharov ?
Can I land with them failing? They don't seem to fail because of this patch.
Yes, you can land if the libc++ CI is green, but thanks for being diligent and asking.
This feels like a change in meaning, from "Assert in debug mode" to "Assert specifically concerned with debug iterators." It turns out that this macro has pretty much always been used with the latter meaning, though, so even though a better name might be _LIBCPP_DEBUG_ITERATOR_ASSERT, I think this is fine.
However, the one place in libc++ that doesn't use the macro with the latter meaning, needs to be updated to use _LIBCPP_ASSERT instead.
I think this should just be _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil"); and if that's not right then investigation is needed as to why that's not right.
Then, please update the summary/commit-message to talk about the semantic change here, which I think is more important than the <string> part. Something like, "_LIBCPP_DEBUG_ASSERT is now used strictly for debug iterators, and disabled during constant evaluation." Observe that this is a change for both <__hash_table> (since ages ago) and <string> (since D115765).