Re:Named Booleans prevent C++ bugs and save you time
by garaetjjte on Sunday February 19, 2023 @03:07PM
(#34861299)
>I was curious if the compiler will optimize in the short circuit even if you extract the eagerly
It will optimize, but not necessarily what you wanted... Because null dereference is UB (with default compiler flags), it's allowed to elide null check.
As an aside. I was curious if the compiler will optimize in the short circuit even if you extract the eagerly evaluated named booleans. However I was pretty sure the rules of c++ are against you and tests show this to be the case
But if you simulate the alias keyword with lambdas then the result after optimization are the same
https://godbolt.org/z/3cczcnK4s