3 ms·
Looking at the link, it generates the exact same assembly (and behavior of course) as void sw(int s) noexcept { switch (s) { case 0
by strbean 7y ago
Looking at the link, it generates the exact same assembly (and behavior of course) as
void sw(int s) noexcept
{
switch (s) {
case 0:
printf("zero\n"); break;
case 1:
printf("one\n"); break;
case 2:
printf("two\n"); break;
}
}
- saagarjha 7y agothatsthejoke.jpg
- strbean 7y agoI mean, parent seemed an awful lot like someone asking what it did. Damn me for missing the invisible /s. I'm sure no other reader would ever be curious!
- saagarjha 7y agoIt's not the comment that is the joke, but the example in the context of the "C obfuscation tricks" article where it's just a convoluted way to write the same thing as a simple C construct.
- inetknght 6y agoYup. Of all of the examples on that page, this is the only one new to me. I thought it pretty clever and after toying with it, it does seem pretty cool with functions as the conditionals.
- lostmsu 7y agoIs noexcept here the consequence of while? Or noexcept simply does nothing at all? Not a C expert, so just curious.
- eMSF 7y agoAFAIK noexcept is a C++ specifier that isn't valid C. Even so, it has nothing to do with the loop, but in C++ it would cause the program to terminate if an exception occurred in the sw function.