- 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
TRWTF: Claiming that declarations are always ordered alphabetically, when clearly they are not!
This is how to do it correct:
Admin
This representative line really just says it all:
Admin
Article is passable levels of WTF. TRWTF is that the main page says '1 Comments' when it's simply @PaulaBean's comment on the subject telling us there's a post.
Admin
I don't get it, why the two-space indentation after
typedef
, while others are 4-space indentation? Perhaps this is TRWTF?Admin
TRWTF is suggesting
getopt()
instead ofboost::program_options
when the article is clearly based on C++.Admin
Admin
Admin
No it doesn't.
The ANSI C assert function does not provide an argument for a message, but when the assert fires it does print out the expression that caused the assert failure.
The && "Something" is a very common way to ensure that there is some human readable description when the assert fails, so that you aren't left guessing what the hell happened.
The use of false is a very common way to force the assert to occur. It's usually used if you want a run time check that is in both release and debug builds, but still want to assert in debug builds to make it easier to find that something went wrong.
You could argue whether the assert itself was necessary, and you can argue whether the standard C assert function is TRWTF. But none of that is representative of the mess that is the rest of the code.
Admin
Fuck frist. I am glad to be combo breaker.
Admin
Yes, I know, I know.
I once had somebody seriously suggest using some bits of boost for a project I was doing. A project that was written in C, and which targetted a rather small Atmel µC.
Filed under: Why don't my damned <sarcasm> tags show up?
Admin
Admin
should be changed to:
But you're basically right, so I'm really not going to argue the point of semantics.
Admin
Admin
Cannot find cornify. Please advise.
Admin
Admin
Will this even compile in a DEBUG environment? Those assert calls try to use a bool and a string as arguments to &&. Please tell me somebody did not overload that operator that way!
Admin
Compile? Yes. While they run, OTOH?
Admin
Argle. All those ::std::{thing} references make my teeth itch. What's wrong with just "std::{thing}" instead? (Yes, I know, leaving out the initial :: leaves the code open to sub-namespaces called std, but really, who does that, and can I strap whoever it is to the noisy end of my GAU-8?)
Admin
Yes, Discourse is so modern you have to escape your own entities!
Admin
This is obviously low-level code for Python. The other types will be implemented later.
Admin
Admin
Admin
Admin
Admin
Admin
Admin
I think you might be surprised. Organized crime is probably run better than most software houses.
Admin
Offers were made that couldn't be refused.
Admin
There is no such thing as strings in c. The characters between quotes evaluate to a const char * in this case, which can be bool tested for nullity.
The string is added to help clarifing the error message when the assert is triggered at runtime. The typical assertion error messages just show the file name, line number and the text passed to the assert macro ". So the author just hacks more text inside.
Admin
Leave math and division by zero out of this.
Admin
At least 2 memory allocations and object constructions, along with more than half a dozen function calls, just to do this?
P.S. the code in this WTF doesn't replace getopt(), even if you use getopt() you'd still need to parse the individual parameters to an option in various types (which is what this code is supposed to do.)
Admin
Admin
Captcha: plaga. Discourse is a plaga on both our houses.
Admin
There is NO reason for "assert...goto exit". That's its own WTF right there. No, if you disable asserts so that they don't do anything, you should STILL NEVER EXECUTE THE GOTO, BECAUSE YOU SHOULD NEVER GET TO IT IN THE FIRST PLACE.
In a test build, you should use assert to ensure that the application isn't about to blow up. The assert gives you specific information on what happened (which should've never happened) and where. Ever getting to an assert that is written to always fail means that a critical bug exists in your application. In a release version, the program silently "goes somewhere else" and ignores that critical bug. That is TRWTF.
If the original programmer wanted to gracefully return false when an invalid context option was specified (and, there could certainly be valid reasons for wanting to do that), using assert at all was simply inappropriate.
Admin
Admin
In a release build, the code can never execute. It is an unreachable block of code, so it doesn't MATTER that the assert does nothing. You've TESTED it. Or were your customers supposed to do the alpha testing for you? In that case, better to leave the assertions enabled!
"goto exit" is never a safe alternative when your assertion does nothing. NEVER. At the very least you should have a runtime error check with a big warning "This should never happen, please inform the person who wrote this that there's a critical bug in this code".
A failed assertion should mean that there is a CRITICAL BUG: something that should never have made it out of testing. Assertions are NOT meant for runtime error checking. If you can simply sidestep the offensive block of code without fear of any bad things happening, then DON'T USE AN ASSERTION. You can use #ifdef and log something in your debug builds, if you want, but don't use an assertion.