News for hackers. Stuff that matters.
Re:Named Booleans prevent C++ bugs and save you time by saghm on Saturday February 18, 2023 @02:03PM (#34849934)
Not necessarily; in first case, the stuff after the `&&` will definitively not be run. In the second case, it depends on how the code is optimized, and there's no guarantee that things moved to intermediate variables won't still be evaluated even if they're never used. Since the compiler presumably can't know the value of the boolean at runtime, it would need to reorder things to avoid doing the unnecessary work, and I wouldn't think it's something that you could just assume.

There are no comments on this comment yet.