logoalt Hacker News

IshKebabtoday at 4:41 PM1 replyview on HN

It's definitely a footgun, but the compiler isn't doing weird stuff because the assertions can be disabled. It's doing weird stuff because there's UB all over the place and it expects programmers to magically not make any mistakes. Completely orthogonal to this particular (fairly minor IMO) footgun.

> I’ve worked as a C++ programmer for 12 years and I’d say it’s probably 50/50 in practice how many people would spot that in a code review.

Spot what? There's absolutely nothing wrong with the code you posted.


Replies

jmalickitoday at 6:49 PM

That assert could completely fail to fire if inlined into another function that did a dereference first.