Re:Catch-23: The New C Standard Sets the World on Fire
by benj111 on Sunday April 02, 2023 @05:08AM
(#35408609)
But this example isn't adding a constraint. The if statement is getting optimised away???
[ Parent
| on HN ]
Re:Catch-23: The New C Standard Sets the World on Fire
by masklinn on Sunday April 02, 2023 @05:46AM
(#35408847)
It is adding a constraint. The constraint is that argc can’t be smaller than 2. This is a literal “can’t”, as far as the compiler is concerned it’s a logical impossibility.
The branch containing the unreachable() obviously gets removed but the compiler then propagates the constraint (the condition for that illegal branch), and can prune any other path where `argc <= 2` upstream and downstream, as they are dead code per the constraint.