kit

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

ctl_shortcircuit_val.c (422B)


      1 /* Short-circuit && / || used for their *value* (0/1) rather than as an if
      2  * condition. The compiler materializes a boolean via compares and conditional
      3  * branches/selects. volatile operands keep them real. (a&&b) is 1, (c||d) is 1;
      4  * 1*20 + 1*22 = 42. Exit code 42. */
      5 int test_main(void) {
      6   volatile int a = 3, b = 4, c = 0, d = 5;
      7   int p = (a && b); /* 1 */
      8   int q = (c || d); /* 1 */
      9   return p * 20 + q * 22;
     10 }