News for hackers. Stuff that matters.
Re:Google broke a conditional statement that verifies passwo... by kbelder on Thursday July 22, 2021 @08:04PM (#27925824)
Yep, I'd prefer that option, despite its wordiness. Obviously this depends a lot on individual preferences, and in this simple example it really doesn't make a lot of difference.

I imagine the compiler spits out pretty similar code either way. It's more just a recognition of my own limitations... I'm a lot less likely to screw up something up, the more explicitly it's written out.

When I was a younger man, I wouldn't have bothered.

Re:Google broke a conditional statement that verifies passwo... by zarzavat on Thursday July 22, 2021 @09:46PM (#27926384)
The problem with that code and the reason that it is often considered bad C++ practice is that it is very easy to accidentally move the inner conditional outside of the outer conditional, thus creating undefined behaviour.

Putting the null check in the same line as the usage means that it is much harder to separate them accidentally.