-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
boost::span: Add BOOST_ASSERT() to catch undefined behavior more easily #188
boost::span: Add BOOST_ASSERT() to catch undefined behavior more easily #188
Conversation
d429122
to
274ae55
Compare
274ae55
to
761c2b7
Compare
761c2b7
to
04298d9
Compare
@SoapGentoo See b0fc739 on branch feature/span. I wanted to see if not losing C++11 constexpr was possible. I'll add more constexpr tests. The initial ones are just to cover the new asserts proposed. |
@glenfe sure, that's fine too |
@glenfe is it legal to call some form of |
@SoapGentoo This would be usable in C++11 constexpr:
Looking into other approaches too. |
@SoapGentoo Merged 24a8174 and a subsequent commit after the tests passed on the feature branch. The idea is to now see what else breaks, if any, before adding more. Eventually, I would just replace |
I'm not sure I like this that much. It foregoes the use of BOOST_ASSERT for everyone just because GCC 4.x/5 doesn't support it in constexpr, but the number of users of constexpr spans under GCC 4.x/5 -std=c++11 is zero and will remain zero. Plus, it makes available a macro (BOOST_CORE_ASSERT) that sounds and looks like a recommended replacement for BOOST_ASSERT, and it definitely isn't one. |
If the macro is not public, it should definitely have And I agree with Peter that we don't need another public assert facility. |
No disagreement about the name. It was intended to be private. Renamed accordingly. |
I think that this should just use BOOST_ASSERT and disable the constexpr tests for GCC 4.x and 5/c++11, as there's essentially zero demand for C++11 constexpr use of span (if you try actually writing constexpr code using spans you'll see that C++11 is completely unworkable.) But failing that, the detail macro should fall back to BOOST_ASSERT when the compiler isn't GCC 4.x or 5. I'm not sure whether avoiding Config here makes any practical sense, but I suppose that's a matter of taste. I'd just use BOOST_WORKAROUND(BOOST_GCC, < 60000) instead. |
It's not just the constexpr tests that would fail on GCC 4.x it's also the regular span tests. |
What I do in Boost.Array is remove the Not sure why GCC 5 is OK with that there, but isn't here. |
Probably because it isn't tested yet. :-) |
In Boost.Array's case, I had already written a test for the asserts so removing the asserts for GCC 4.x actually broke it and I decided to remove the constexpr instead. |
@glenfe @pdimov