kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

sw_default.c (525B)


      1 /* A switch whose DEFAULT arm is taken: the selector matches none of the listed
      2  * cases, so the dispatch must fall through every comparison to the default
      3  * label. volatile selector defeats folding. Selector 77 matches nothing, so
      4  * the default returns 42. Exit code 42. */
      5 int sel(int x) {
      6   switch (x) {
      7     case 0:
      8       return 10;
      9     case 1:
     10       return 11;
     11     case 2:
     12       return 12;
     13     case 3:
     14       return 13;
     15     default:
     16       return 42;
     17   }
     18 }
     19 int test_main(void) {
     20   volatile int x = 77;
     21   return sel(x);
     22 }