-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
constexpr DEBUG_ASSERT #4131
constexpr DEBUG_ASSERT #4131
Conversation
Pull Request Test Coverage Report for Build 1058111453
💛 - Coveralls |
d3f2b5c
to
2d1918e
Compare
Oh, it turns out we can remove the lambdas completely. |
2d1918e
to
4f95a6d
Compare
src/util/assert.h
Outdated
@@ -52,11 +52,20 @@ inline void mixxx_release_assert(const char* assertion, const char* file, int li | |||
// | |||
// In release builds, doSomething() is never called! | |||
#ifdef MIXXX_DEBUG_ASSERTIONS_ENABLED | |||
#define DEBUG_ASSERT(cond) ((!(cond)) ? mixxx_debug_assert(#cond, __FILE__, __LINE__, ASSERT_FUNCTION) : mixxx_noop()) | |||
#define DEBUG_ASSERT(cond) \ | |||
if (Q_UNLIKELY(!(cond))) { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about replacing (cond)
with static_cast<bool>(cond)
as suggested by @Holzhaus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…rator instead of equality comparison
Unfortunately the error message is a bit weird in case of a compile time assert:
that is also the case with the std assert(), not our fault |
8ca0b76
to
32071a4
Compare
@Holzhaus Merge? |
Didn't test this yet, but feel free to merge if you did. Otherwise I can have a look in the next days. |
LGTM |
Replace the unused conditional assignment by plain if() to make our asserts usable in contsexpr
In case the assertion failed the compiler is already complaining that the assertion is no longer const, because QCritical is not const.