Let's not vague post on HN. What's the problem with the above?
Only when NDEBUG is defined, right?
I think it should be able to. I'm pretty sure assert is defined to call abort when triggered and abort is tagged with [[noreturn]], so the compiler knows control flow isn't coming back.
I don't think this is true. The compiler cannot remove or reorder instructions that have a visible effect.
if (p == 0)
printf("Ready?\n");
*p++;
The printf() can't be omitted.You might be surprised! When it comes to UB compilers can and do reorder/eliminate instructions with side effects, resulting in "time travel" [0].
IIRC the upcoming version of the C standard bans this behavior, but the C++ standard still allows it (for now, at least).
[0]: https://devblogs.microsoft.com/oldnewthing/20140627-00/?p=63...