3 ms·
So instead of short circuiting like that code should when it uses &&, it instead makes an assumption about the first part of the boolean expression because othe
by xmprt 5y ago
So instead of short circuiting like that code should when it uses &&, it instead makes an assumption about the first part of the boolean expression because otherwise the code would have undefined behavior?
- dataflow 5y agoYeah. More specifically, it just inserts whatever behavior it likes for the undefined scenario, which in this case is "the same behavior as in the defined scenario".
- ddalex 5y agoI am utterly confused. How would the compiler know that has_value() guarantees that the ->label dereferencing work, since this is a bitwise operation ?
- dataflow 5y agoI would imagine has_value is checking to see if a pointer is NULL, and -> is dereferencing that same pointer. When the optimizer sees the two together it realizes the former is useless.