US Torture Bill as C code
WARNING: GEEK ALERT
if (person = terrorist) {Can you spot the error?
punish_severely();
} else {
exit(-1);
}
[stolen from via BoingBoing]
« Older and Wisern't | Main | Supermarket Software »
WARNING: GEEK ALERT
if (person = terrorist) {Can you spot the error?
punish_severely();
} else {
exit(-1);
}
[stolen from via BoingBoing]
TrackBack URL for this entry:
http://mt4.sevitz.net/mt-tb.cgi/2395
![]()
4.21-en
Comments
I don't know C, really.
Does the US Torture Bill return errors of:
variable 'terrorist' not defined?
Posted by: QE | October 3, 2006 4:39 PM
Just got it (d'oh!).
I notice also that punish_severely() takes no arguments, presumably punishing globals, so to speak.
Posted by: QE | October 3, 2006 4:52 PM
There was only ever going to be one or two people who could possibly comment on this post (apart from Babs, maybe, with her usual "nerd alert!"), and you are TOTALLY one of them QE, nice one!
Yes, there are no arguments to punish_severely(). I take this to mean that if you're defined as a terrorist, there's no defense.
Hence the unlimited detention period with no trial, in Cuba, etc.
Posted by: Matt | October 3, 2006 5:25 PM
I don't get it, and NERD alert ahoy!! :P
Posted by: Babs | October 4, 2006 8:40 AM
Like, as I said. :-)
Posted by: Matt | October 4, 2006 10:52 AM
Erm... did you mean to use the assignment operator '=' or should that have been the equality operator, '==' ???
In this case 'terrorist' will be assigned to 'person' and (provided the result is non-zero) the condition returned as true. This will effectively label all persons as terrorists...
Posted by: SharkyUK | October 4, 2006 1:04 PM
Ok, so I just read the link to the source article... apologies as I have just repeated what they say over there. Oopsies.
Posted by: SharkyUK | October 4, 2006 1:05 PM
Oopsies indeed!
As you say:
(person = terrorist)
Is the error, as it doesn't follow the 'if' argument.
(person == terrorist)
Will only return true if the person really is a terrorist. Using the single "=" assigns ALL persons to be terrorists, which amounts, in simple English, to "guilty until proven innocent".
Or like, something. It's all Greek to me. But I still kinda get it.
Posted by: Matt | October 4, 2006 1:12 PM
Yep, I had to comment.
Going back to geek mode for a moment (like I ever leave...): 'person = terrorist' doesn't label everyone a terrorist, it replaces each person with a terrorist, losing all knowledge of the person they previously were.
Which may be exactly the kind of reaction the bill will get...
Posted by: QE | October 4, 2006 3:15 PM
So now that you can read code you can start doing your own html fixes.
:)
Posted by: Adrian | October 6, 2006 9:20 PM
Telling the difference between = and == does not does not imply that I 'can read code'. Besides, I thought this here blog was coded in php?! :-P
Dude, I'm tryin'. Doin' my best.
Posted by: Matt | October 6, 2006 9:35 PM
Come on, if you can complain about my 'deprecated' tags (which aren't, by the way, they just won't be in the core when the spec goes modular) then you can learn HTML, then PHP.
Find a project ;-)
Posted by: QE | October 9, 2006 1:37 PM
Err... I believe Lifewithouttoast.com IS my 'project'.
I don't work with IT/computers/internet/anything, it's just a hobby, so I can only learn it if and when I have the time or the inclination.
Admittedly, having LWT as a project gives me ample inclination, so now it's just a case of having the time. Which I only do occasionally.
Someday, I will know all I need to know. Until then, err... Help?
Posted by: Matt | October 9, 2006 2:38 PM
To be honest, it's not even going to get as far as the incorrect use of the assignment operator. There's no preprocessing directive, no function definition and no variable declaration. For all we know, person and terrorist may be incompatible data types and you'd need to 'cast' the 'terrorist' variable.
There's a disappointing lack of Hungarian notation too but that wouldn't necessarily stop it compiling.
Posted by: Dragon | October 11, 2006 10:01 PM
Err... Yes! I'm in total agreement. But then again, it's only a snippet, and even at that, it's only a parody of a snippet.
This post is serving well to root out the true geeks among our readership here on the LWT, I have to say!
Posted by: Matt | October 11, 2006 10:46 PM
If we're trying to root out the geeks, I think Dragon just won a prize or something.
But then we should probably cut some slack for people who need (or have needed) to know this stuff professionally. Did I hear someone say they 'don't work with IT/computers/internet/anything'?
Posted by: QE | October 12, 2006 1:11 PM
That would be me. It's a hobby. I use computers in work, for emailing, spreadsheets, stuff like that, but not for knowing the nuts and bolts and innards and guts of them. That bit is purely a hobby.
Dragon totally just won a prize. :-)
Posted by: Matt | October 12, 2006 1:37 PM
I only ever learnt C and C++ so that I could hack the pak files in Quake 3/Doom 3 and make my noob pistol deal out 1000+ damage per shot or something
Posted by: Dragon | October 13, 2006 4:51 PM
You still win a prize though. :-)
Mind you it will probably be a "prize", like the one offered on the podcast.
Posted by: Matt | October 14, 2006 11:40 AM