Your Worst "Gotchas" ever in programming

Started by
68 comments, last by Icebone1000 11 years, 2 months ago

Semicolons are just as easy to miss even if you put the brackets in a different line.

You guys should seriously upgrade your language and tools!

Screen%20Shot%202013-02-12%20at%207.41.3

Notice the squiggly under the semi-colon, and under something. Also notice that the code inside of the brackets is greyed out. That's because the tools are smart enough to detect that the code inside the brackets is never executed.

Advertisement

Semicolons are just as easy to miss even if you put the brackets in a different line.

QFT, happened once or twice to me.
The good thing is that those kind of mistakes (with infinite while loops) are very easy to debug!
The bad thing was, I didn't yet know how to use a debugger. tongue.png

@tstrimple: Sadly, my IDE of choice doesn't do that. sad.png

(I use QtCreator, which is fairly modern, and includes alot of C++11 syntax highlighting for things like lambdas and such)

Macros with more lines and semicolon? Used and a bracket-less one liner in if/for/whatever statements? Got me once. I had to come here with it then feel the facepalms

For me it was before I learnt the use of arrays, I used to declare every variable independantly and used copy/paste a lot, I lose track of the number of times I forgot to change a number and had two values trying to store in the same variable. One simple number cam cause so many issues.

The good thing is that those kind of mistakes (with infinite while loops) are very easy to debug!

Then you do it with an if statement and you go crazy as the program behaves strange and you can't tell why. Even worse is if instead of behaving strange it ends up behaving exactly the same as the previous build... You'll go insane trying to figure out what did you forget to make the condition true.

Also reminds me, somebody I know says that you should always get somebody else to look at your code because you will always read what you intended to write, not what you actually wrote.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

Semicolons are just as easy to miss even if you put the brackets in a different line.

You guys should seriously upgrade your language and tools!

Screen%20Shot%202013-02-12%20at%207.41.3

Notice the squiggly under the semi-colon, and under something. Also notice that the code inside of the brackets is greyed out. That's because the tools are smart enough to detect that the code inside the brackets is never executed.

Is this VS 2012? It looks like C#.

Semicolons are just as easy to miss even if you put the brackets in a different line.

You guys should seriously upgrade your language and tools!

Screen%20Shot%202013-02-12%20at%207.41.3

Notice the squiggly under the semi-colon, and under something. Also notice that the code inside of the brackets is greyed out. That's because the tools are smart enough to detect that the code inside the brackets is never executed.

Is this VS 2012? It looks like C#.

I did say language and tools. ;)

Yes, VS 2012.

Default arguments are fucking evil.
struct Base
{
    Base(int value1, int value2, int* pvalue3 = NULL);
};

struct DerivedOne
{
    DerivedOne()
        : Base(1, 2, NULL)
    {  }
};

struct DerivedTwo
{
    DerivedTwo()
        : Base(3, NULL)
    {  }
};
Spot the bug.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

It looks like C#.


I did say language and tools. ;)

Oh, don't worry on that account, we already upgraded our language. wink.png
Which, incidentally, also solves ApochPiQ's bug in the post above this.

I did say language and tools. ;)

That the language still allows you to make that exact same mistake in exactly the same way doesn't make it look like an upgrade =P

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

This topic is closed to new replies.

Advertisement