|
When I track the packages they typically fly into Los Angeles.
To err is human. Fortune favors the monsters.
|
|
|
|
|
|
Great song!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Too late, already pressed F5, Someday I or someone will get a mild chuckle.
|
|
|
|
|
Better than a semicolon at the end of an "if" statement. took me a half day to realize why my coworker's code is not working.
Advertise here – minimum three posts per day are guaranteed.
modified 12-Apr-23 12:31pm.
|
|
|
|
|
Yeah, I've done that more times than I care to admit.
|
|
|
|
|
Their cod wasn't working? That sounds fishy to me.
|
|
|
|
|
Edit: got it (the fishy part)
Here, let me clear the picture:
<pre lang="C++">
if(obj->nVar > 0);
{
//unreachable code
//more unreachable code
//even more unreachable code
}
It was verry confusing because it was CLI manageable section and without a special pragma you cannot debug this code.
Advertise here – minimum three posts per day are guaranteed.
modified 12-Apr-23 12:31pm.
|
|
|
|
|
um... Not only would that ode be reachable, it would be executed every time.
Truth,
James
|
|
|
|
|
Yes, exactly - bad wording on my side.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
|
Pete O'Hanlon wrote: heir cod wasn't working? That sounds fishy to me.
Beware of people with a non functional cod piece.
|
|
|
|
|
Mind bleach, I need mind bleach!!!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
For some reason - maybe it's my editor? - but lately I've been dropping a lot of { open braces after if (K&R style for me in C/C++) and it rains absolute mayhem down on my source code. My editor lights up like a $5 {expletive, use your imagination}, and of course nothing compiles. It's also just the sort of thing your brain will fill in for you automatically if it's not there while scanning code. Thanks brain!
To err is human. Fortune favors the monsters.
|
|
|
|
|
Yeah, with K&R your brain will register the harmful semicolon. But I for instance always use Allman style with any language.
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|
|
Single Step Debugger wrote: always use Allman style with any language.
If you can: GO forces you to use K&R style. Allman is a syntax error
Mircea
|
|
|
|
|
I always use braces, even when not required. It future proofs for later maintenance.
There was a great article supporting the always use braces approach, but I can’t remember the exact format used.
The article had extensive test cases around merging changes from multiple branches and showed how braces protected correct merging.
I have tried googling it, but with no luck. I guess I could just Chat GPT to provide the answer now? And if I do not like the answer then I will ask Chat GPT to write a white paper proving that my preferred brace style is superior and force my team to adopt it.
|
|
|
|
|
I *was* using braces. I'm talking about typing:
if(foo!=nullptr)
printf("foo valid\n");
}
Like that.
To err is human. Fortune favors the monsters.
|
|
|
|
|
At least it is a syntax error. That is a scenario where you can ask the editor to re-format for you and then compare with pre-format to see what shifted/indented unexpectedly.
Like you said, the indentation will trick you into not noticing the missing {.
The one that bit me was
if ()
foo();
and I added prefoo(); ahead of foo(); without adding braces.
“It was a setup, I tell you, wiseguy”
|
|
|
|
|
This is why I *always* use braces after an if is there is only one line of code ...
if(expression == true) {
doSomething();
}
Then later when reviewing my code, I decide to tidy it up because it looks nicer ...
if(expression == true) doSomething();
Third time around I add one line of code and spend the rest of the day trying to figure out why nothing works.
Nothing succeeds like a budgie without teeth.
To err is human, to arr is pirate.
|
|
|
|
|
Yeah, that's not a fun bug. Fortunately for me, the number of times that has happened to me I can count on one hand.
To err is human. Fortune favors the monsters.
|
|
|
|
|
That closing curly kicks my OCD right where it hurts.
|
|
|
|
|
Message Closed
modified 12-Apr-23 12:44pm.
|
|
|
|
|
|
Single Step Debugger wrote: Better than a semicolon at the end of an "if" statement.
That's a fun one. Back in my college days, a fellow student (much older than the rest of us, I think he decided to go back to college in his 40s) had the habit of leaving his system logged in, with his editor running...so whenever he took a break to (typically) go pick something up at the cafeteria, we'd do things like adding a bunch of spaces after a for loop and then a semi-colon (so it's off-screen and not visible), so his code read:
for ( int i = 0; i < someLimit; i++ ) ; <-- not visible without scrolling horizontally
{
}
We did it many times, but he never learned to lock his workstation...fool me once...
Poor guy. He was already struggling, and we made him waste a lot of his time on things like this...
Gaetan, wherever you are, I hope you still had a successful and rewarding career...
|
|
|
|
|
That's so evil! I like it!
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|