News for hackers. Stuff that matters.
Re:C Posix complaint argument parsing in 42 loc, inspired by... by cesarb on Thursday January 05, 2023 @12:11PM (#34262965)
The way "switch" works in C is very weird. It behaves more like a "goto", where each "case ...:" is a label to which it can jump.

So when the character is '-', it starts just before the "if (0)" (this part is hidden within the ARG_BEGIN macro), and as you noted, it will never enter that block. However, when the character is 'a', 'b', 'c', or nothing (the end-of-string marker), it will jump directly to the corresponding "case ...:" label, even though it's within that "unreachable" block.

There are no comments on this comment yet.