Torture in C

From Bruce Schneier's blog, the following is a small piece of C code summarizing the terrorist treatment bill.


if(person = terrorist) {
punish_severely();
} else {
exit(-1);
}

This code segment is apparently trivial. However those familiar with C programming might notice a small but important subtlety in the code. See it?

2 thoughts on “Torture in C”

  1. The condition uses an assignment (=) instead of an equality comparison (==), so it tacitly assumes the person is a terrorist no matter what (assuming ‘terrorist’ has a nonzero value). Reading the blog, apparently that was intentional.

Leave a Reply