Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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;
        }
    }


Is noexcept here the consequence of while? Or noexcept simply does nothing at all?

Not a C expert, so just curious.


AFAIK 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.


thatsthejoke.jpg


I 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!


It'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.


Yup. 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: