3 ms·
The fact that bar could exit or not return doesn't matter (although it was indeed my initial line of reasoning) as if the value is null bar won't be called and
by gpderetta 4y ago
The fact that bar could exit or not return doesn't matter (although it was indeed my initial line of reasoning) as if the value is null bar won't be called and UB happens; hence the value can't be null and bar can be called unconditionally. The value is still dereferenced only after calling bar.
Still gcc doesn't optimize the check away so it is possible there is some other line of reasoning that prevents the transformation.