Re:C++26: A User-Friednly assert() macro
by pwdisswordfishy on Sunday March 29, 2026 @02:44AM
(#47560903)
But if the assertion fails, the program is aborted before the pointer would have been dereferenced, making it not UB. This explanation is bogus.
[ Parent
| on HN ]
Only if the assert is active. It basically means that the code is invalid when NDEBUG is set.
Re:C++26: A User-Friednly assert() macro
by quuxplusone on Sunday March 29, 2026 @10:02AM
(#47563229)
When NDEBUG is set, there is no test, no assertion, at all. So yes, this code has UB if you set NDEBUG and then pass it a null pointer — but that's obvious. The code does exactly what it looks like it does; there's no tricks or time travel hiding here.