- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Or a Radiohead fan
Admin
#ifdef REQUIRES_LOGIN
define 4 5 BUT_ONLY on lefthandside
#endif
Admin
Do I get extra credit for recognizing CodeIgniter? ... No? ... Ok...
Admin
Nah, it's because 2 is defined as a variable The function logged_in() can modify that variable, thus enabling or disabling the following code block....
Admin
Then 2+2=3 and you keep the change.
Admin
Admin
On the other hand, you could probably safely remove all "|| true"s.
Admin
It was thrown so it could be caught. Just try and you will understand.
Admin
2.4 + 2.4 = 4.8
If you round those values to the nearest integer you get:
2 + 2 = 5
Admin
Even that will fail if == has been overloaded so that it no longer tests for equality or modifies the value of two.
Admin
Wow, considering the number of replies, this is the best troll ever!
Admin
lol...pentium math error. good old days.
Admin
His logic is so wrong 2+2 obviously equals 10 (base-4).
Admin
I imagined this as authentication code running on a server. So it won't matter what your users are running; it will matter what you are running. And it will always evaluate as true or false for all users (even assuming your theory).
Admin
THERE. ARE. FOUR. INTEGERS!
Admin
Agreed. I would add code review and any testing from build verification to user acceptance to the TRWTF?
Admin
Admin
TRWRF is so called programmers who don't know shit about Boolean logic, including the dreaded "if foo then return true; else return false;" antipattern, or other lengthy if-else-spaghetti code (or worse, goto) instead of a simple Boolean expression.
Admin
Admin
Admin
It is a commonly accepted practice to place OR logic into a conditional in order to bypass some dependency for testing purposes, or to stub out code that will do an authentication check at some later point, but is OK to leave unauthenticated for now. George Z should tread carefully in this code, lest he introduce a defect into something that is working in production.
Admin
Or 2+2=11 (base-3). Of course, if the compiler is using base-3 or base-4 arithmetic, then "4" is an undefined value and this expression should generate an error (the same as if it was "2+2=Fred" (unless, of course, Fred is 4)).
Admin
Admin
by both boolean logic (and operator precedence in most programming languages) A || true evaluates to the same as A...
adding the || true in that case would not change the truthiness of the expression.
Admin
We all realize, of course, that logged_in() has side effects, and this is a way to ensure that those side effects take place while in effect throwing away the result of the check?
Admin
or you could throw in a //BUGBUG and scan for those before releasing
Admin
Rather than relying on stupid codes, use source control. hg status to see which files you changed, and then revert them. Or if you've committed, hg diff -r with the revision before the changes.
Admin
Nice try Mr. Boolean Troll, but it fails with three-valued logic.
Admin
I feel obligated to write this since no one has done it yet. TRWTF is PHP!
Actually, TRWTF is PHP syntax... who thought about using -> for object access? Really, what's the explanation for using TWO signs (which in es_ES keyboards takes THREE key-strokes) when a dot works perfectly fine in almost every other language in the world?
If you wanted to fuck up the syntax, why not use _> which takes 6 key-strokes?
Admin
Admin
There's a good reason why it would complain of unreachable code.
Because it is.
Admin
Admin
Admin
If I remember correctly, from C++, which PHP is written in:
a.MyValue() if a is a reference a->MyValue() if a is a pointer
-> looks like a pointer, get it?
Admin
I can't even find those keys :-)
Admin
Maybe consider using a normal keyboard? Seriously, {, [, ], } and \ are all three keystrokes on a Belgian keyboard (which has a retarded design, by the way). If programming languages were supposed to be easy to type on every keyboard in the world, we'd be stuck with letters only. Hurray for END IF.
Admin
Now obligatory--
[image]Admin
Admin
Probably didn't know he could just have made it || 1) if he wanted it to always test true.
Admin
I am not using PHP, nor am I building the SQL in the front end. This is dynamic sql as in a stored procedure that builds a sql string based on input parameters and uses sp_executesql to execute it. It is more performant in situations where totally different plans will be generated based on whether you need to join to this table or that table and apply this filter or that filter. Amusing that implode is a built in function of PHP.
Admin
Does this better capture the original programmer's intent:
Admin
Basic optimization knowledge? Been a long time since I seen a compiler that doesn't evaluate constant expressions during compile time unless told not to do so with some command line argument or project configuration.
Admin
The actual WTF here is George's lack of experience that prevents him from understanding debugging patterns and enables him to make fun of it.
Admin
Freudian slip. The code made him throw.
Admin
Kick the fucking stupid cunt to death before the fucker breeds. Too late? Kick its fucking offsping to fucking death too. Burn the dwellings it lived in. Salt the ground it wanked on. Exterminate it from the universe.
Admin
Admin
Poorly written backdoor?
Admin
Admin
When you're a hacker, old habits die hard...
Admin