An end to implicit fall-throughs in the kernel
An end to implicit fall-throughs in the kernel
Posted Aug 5, 2019 15:50 UTC (Mon) by rweikusat2 (subscriber, #117920)In reply to: An end to implicit fall-throughs in the kernel by karkhaz
Parent article: An end to implicit fall-throughs in the kernel
I would suspect assumptions based on how multiway conditionals work in other languages, eg, Pascal or the Bourne shell language, here. Such a construct can be emulated in C by combining switch and break but it doesn't have one. OTOH, a C switch can be used to do things which can't be done with a multiway conditional, eg,
switch ((uintptr_t)p & 3) { case 3: *p++ = c; case 2: *p++ = c; case 1: *p++ = c; }to align a pointer while storing some values (I'm aware that this is not standardized C). One could argue that such cases are rare and that a proper multiway conditional had been a better idea.
Posted Aug 5, 2019 18:40 UTC (Mon)
by rweikusat2 (subscriber, #117920)
[Link]
Posted Aug 8, 2019 3:03 UTC (Thu)
by Paf (subscriber, #91811)
[Link]
What behavior would constitute “fall through” in your view? Fall through simply means proceeding from one case to the next instead of breaking out. C does so unless told otherwise, so it’s implicit. The fact that the generated assembly is just a set of jumps to labels has no bearing on this higher level language observation, which is comparing C to other languages on the behavior of the switch statement.
Basically you’re saying C doesn’t have fall through at all, because a switch statement is just a set of gotos so we should stop talking about this. That’s certainly *a* perspective. It’s not an interesting or useful one and those of us who want to have a name for this behavior that refers to the higher level language are just going to keep talking about falling through cases.
An end to implicit fall-throughs in the kernel
An end to implicit fall-throughs in the kernel