Jump to content

  • Log In with Google      Sign In   
  • Create Account


Your Worst "Gotchas" ever in programming


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
69 replies to this topic

#41 DaBookshah   Members   -  Reputation: 174

Posted 30 January 2013 - 08:43 PM

semi-colon at the end of an if statement.

 

Why are you ignoring the state of the flag?? Why do you keep going into that code block? WHY??

Maybe the code isn't synced with the debugger! I'll rebuild. Nope, same problem. Stupid compiler/debugger/toolchain!

This. So annoying.



Sponsor:

#42 Sik_the_hedgehog   Crossbones+   -  Reputation: 1536

Posted 30 January 2013 - 09:01 PM

Watch this one for a laugh:

https://www.destroyallsoftware.com/talks/wat

 

Seriously, what's with programming languages? =/


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.

#43 Ivko   Members   -  Reputation: 192

Posted 02 February 2013 - 03:07 PM

I wrote a function to apply blurring to an image stored in a 2D array passed in (VS2010, C++). The function had a local 640x480 2D array on the stack. Calling the function caused really strange things to happen and had me baffled while trying to change random things to make it better. In the end, it turned out it was a stack overflow, with the additional array sending it over the top of the default 2MB size. That was a weird one. It would be nice if something indicated the problem in debug mode.



#44 HonestDuane   Members   -  Reputation: 151

Posted 08 February 2013 - 07:45 PM

I once typed this in some multi-threaded server code and spent an hour trying to figure out why things were not working.

 

while(server->active);{
   // Not important.
}

 

 

.. in case you can't see it.. look at the extra ';' and what it creates in the generated logic. 



#45 JonathanJ1990   Members   -  Reputation: 166

Posted 09 February 2013 - 02:46 PM

in my first text adventure i made a casino function that  was supposed to be a place payers could spend their money with an opportunity to make more and use that for upgrades stat boosts, etc.  however i will always remember that function because that was the first time i encountered a rogue curly brace.  I kept running the function and it kept outputting the same exact results, which made the entire structure pointless especially since it was supposed to be a gambling area.  i studied that function for about a week before i decided to just read the entire thing line by line and discovered that by me missing one curly brace the entire function , barring one case,  was ignored by the compiler....... to this day i consider the rogue curly brace my greatest enemy ......



#46 Mayple   Members   -  Reputation: 187

Posted 11 February 2013 - 06:04 AM

I will probably get the your a dummy look.

 

Worked on a game with a group of people using Flixel. Was good but we needed a few things that FlashPunk offered instead. Ported all the code over to FlashPunk. Decided to mock up some UI in good ol Flash oldschool style. Linked everything together and.. voila. White Screen.

 

Tried again day after day after day after day. We were all stumped on why the project file wasn't working.

 

That day I learned I was somehow able to link a .as3 file to a .as2 FLA. I still do this day have no idea how I was able to do it. However when the problem was fixed it still was a white screen.

 

Stepping through everything we relized we were all a bunch of dummys. Line 3 started the Flixel engine. We never started FlashPunk. Everytime we started it we did isolated tests with Flashpunk with some Copy Pasta.. man I felt dumb.


I usually just give my 2 cents, but since most of the people I meet are stubborn I give a 1$ so my advice isn't lost via exchange rate.


#47 way2lazy2care   Members   -  Reputation: 782

Posted 11 February 2013 - 07:24 AM

I once typed this in some multi-threaded server code and spent an hour trying to figure out why things were not working.

 

while(server->active);{
   // Not important.
}

 

 

.. in case you can't see it.. look at the extra ';' and what it creates in the generated logic. 

 

This is a big part of the reason I never open my brackets on the same line as my conditionals.



#48 Sik_the_hedgehog   Crossbones+   -  Reputation: 1536

Posted 11 February 2013 - 11:56 AM

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


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.

#49 mhagain   Crossbones+   -  Reputation: 7564

Posted 12 February 2013 - 06:43 PM

memset (&mywonderfulstruct, 0, sizeof (&mywonderfulstruct));

The evils of copy-and-paste, and it's so bloody subtle; thankfully I noticed it right away but damn - it was close.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#50 Casey Hardman   Crossbones+   -  Reputation: 2175

Posted 12 February 2013 - 07:15 PM

I once made a switch() with a few cases in it, then I decided I'd prefer it as a series of if's and else's (I needed more control)...but I left the 'break' statement in one of the if's...then copied and pasted that if a few times, with the 'break;' still there...

 

In short: bye 30 minutes, I'm sorry I didn't make much out of you



#51 tstrimple   Prime Members   -  Reputation: 1718

Posted 12 February 2013 - 09:44 PM

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. 



#52 Servant of the Lord   Crossbones+   -  Reputation: 17908

Posted 12 February 2013 - 09:58 PM

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)


Edited by Servant of the Lord, 12 February 2013 - 10:00 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                            [Need web hosting? I personally like A Small Orange]
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#53 szecs   Members   -  Reputation: 2102

Posted 12 February 2013 - 11:05 PM

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



#54 u1bd2005   Members   -  Reputation: 170

Posted 13 February 2013 - 09:01 AM

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.



#55 Sik_the_hedgehog   Crossbones+   -  Reputation: 1536

Posted 13 February 2013 - 11:44 AM

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.

#56 smr   Members   -  Reputation: 1588

Posted 13 February 2013 - 01:30 PM

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#.



#57 tstrimple   Prime Members   -  Reputation: 1718

Posted 13 February 2013 - 01:36 PM

 

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.



#58 ApochPiQ   Moderators   -  Reputation: 14617

Posted 13 February 2013 - 02:05 PM

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.

#59 Servant of the Lord   Crossbones+   -  Reputation: 17908

Posted 13 February 2013 - 02:13 PM

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.


Edited by Servant of the Lord, 13 February 2013 - 02:17 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                            [Need web hosting? I personally like A Small Orange]
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#60 Sik_the_hedgehog   Crossbones+   -  Reputation: 1536

Posted 13 February 2013 - 02:39 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS