- 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
// love CPP #define true !toggler #define false toggler #define void static int toggler; void #define ToggleFilter(X) ToggleFilter() { toggler=!toggler; }
struct no_error_here__dude
// Spoiler: This fix is untested
Admin
Admin
You assume there was a Q&A department to catch it in the first place. You also assume the shop uses tests.
Admin
I don't see the problem... the code should work just fine!
Admin
Yep, and this proves that this forum has more QA than the company where the original code was written ;)
Admin
I suspect the unit tests were all done using compiler directives and thus passed with flying colours.
Admin
My Eyes! - Nice one abx. You made me laugh.
Admin
Pretty much.
Admin
Admin
I ... don't understand...
Admin
Somebody obviously had a deep insight into the difference of compile time and runtime ;)
Admin
strange.. I always thought that toggle function would return one of 3: true, false, fileNotFound... Here the hell is fileNotFound!?
Admin
Admin
excellent wtf =)
Admin
"The Sussman" is teh brillant. He am be teh n00b?
Admin
The more I look at this, the more stupid it seems. I was going to write stupider but I figured people might not see the irony.
It is stupider though.
Admin
If you don't know C well enough to know that #define isn't handled at execution time you shouldn't be writing production applications
Admin
Thats basically every microsoft programmer I've ever seen.
Admin
It was for a graduate parallel processing course I was taking. The program used the same algorithm to do some matrix work (I think I was inverting matrices) using a number of different variations in how much data was passsed to each processor and how much it did before passing it to another processor or processors.
The code was mostly identical with some changes depending on the details of each set of parameters.
So when compiling the program, there were a number of #ifs to determine the depth of nested compilations, #undefines to undefine the previous parameters and #defines to define new paramaters. And then, after the code was compiled, except for the final path, it would #include itself for the next pass.
The program worked great, but it was one of the most miserable things I ever debugged.
Admin
Looks like someone was coming in from an interpreted language and didn't realize that C/C++ were compiled. (or even worse, for some reason they were used to using an interpreted version of C!)
Admin
Pain in the arse how you have to press a button, or run a makefile or use a command simiar to cc to ghet these damn interpreted programs to work these days....
(and has anyone mentione brillant over brilliant yet....)
Admin
The very vact that this sort of thing gets through suggests to me they do have a QA dept - QA (in my exp) is useless - it tends to be a whole bunch of suits who can calculate meaningless statistics to satisfy Six Sigma, ITIL, CMMI or any other methodology/framework that helps convince themselves that they are somehow better off since spending the money and getting all their programmers trained in aforementioned framework - I especially love Six Sigma's 'Cost of Quality' vs 'Cost of Poor Quality' which boils down to a calculation of bugs vs potential bugs - Potential bugs would only include the ones they thought of, so they would (almost always) not exist - their results would be skewed because potential bugs could be as high or as low as you pleased (and how many undetected bugs may still exist that have not been discovered {and therefore aren't even potential bugs}?)
QA not picking it up is no surprise to me... What does surprise me, though, is that presumably the code was reviewed and (hopefully) tested. How this ever made it to production remains a mystery....
Admin
I guess that company employs an innocent victim who has to explain to the overrated employee who wrote it why it doesn't work as expected. Of course they can run CPP to see what's wrong, but they do not have time to learn it, so they prefer to let someone smarter than them explain it forever. Well, instead of telling someone smarter than you that he or she is paid to explain you the basics of C++, RTFM!
Admin
Not only is this the most cretinous perversion of "process" I have ever encountered, but it has particular relevance to the code currently under discussion. I mean, CMMI only goes to level 5. This goes waaaay up there ... possibly even to level 11.
Admin
This is why students should be taught what goes on inside a compiler, even if invoking it is as trivial as pressing a single key. There are many, many bugs (or 'design issues') that could be prevented if the programmer only knew what's going on behind the scenes.
Admin
Admin
Bravo! That's one of the better WTF's I've seen on this site. It looks like clean code, it even makes sense to the casual reader, but it's oh so very wrong.
Admin
HAHAHAHAHAHA! do nothing.. hoooo... heheheh.
Admin
Which coincidentally describes MFC itself, beeblebrox - it really is a legacy framework, even if it's still being used. People do new things with all kinds of legacy tools for all kinds of reasons.
Admin
Admin
Admin
The real WTF is that you printed 12 pages to get the one post you wanted?
Admin
Wow... That's all I can say...Preprocessor toggle code...I mean it doesn't MAKE ANY SENSE!!!
Admin
Code like this makes me wish for android overlords to ruthlessly cull incompetents from society.
Admin
Sorry for being dumb (or being a C(++) ignorant) but what is the problem with the code? Does undef or define not do what it says it does? From just looking at it first glance, it "seems" right...
ashamed
Admin
Now I'm even MORE ashamed...
I admitted already I was a C-ignorant...
The reason why I didn't read through the COMMENTS first to see what might be the WTF (which I NOW understand) is - they DID NOT SHOW...
ashamed^2
Admin
Compiler vs. Runtime understanding FAIL.
Admin
Legacy software: the pre-'if' days!
Admin
Admin
It always annoys me to see code like this:
function isSomethingTrue() { if (condition) { return true; } else { return false; } }
when this would do:
function isSomethingTrue() { return condition; }
Not really the point of this WTF I know but I just had to get it off my chest
Admin
LOL, no. Just the 1. 'Print preview' and the range selection bits of the print dialog are your friends. :)
(Well, ok, I printed 3, but that's down to firefox refusing to print any of the comment text despite the preview looking just fine.)
Admin
Admin
I think someone toggled a concept in his brain:
Preprocessor Logic vs. Runtime Logic
Admin
That would be "Brillant" ;)
Admin
Admin
#define GOTO_COLLEGE
#ifndefine GOTO_COLLEGE #define BUY_DEGREE #endif
#if defined(GOTO_COLLEGE) graduate(); #else if defined(BUY_DEGREE) cheat_and_graduate(); #else bribe_and_graduate(); #endif
he clearly didnt cheat or bribe anybody to graduate :)
Admin
lol makro-madness
Admin
Admin
Yes, and this is important to me because it means that, while the code is definitely broken, the IsFilterEnabled() function would still return the correct value so that it is logically correct. Having something be broken and correct at the same time makes it more funny.
Although at least one other poster has pointed out that this only works if the #define ENABLE_FILTER at the very top is in the same file (and precedes) ToggleFilter().
-- Furry cows moo and decompress.
Admin
University Education: $10 000 Desktop Computer: $3000 Visual C++ IDE: $500
Not knowing the difference between a variable and a compiler directive: priceless