for(int i = 0; i < stuff; i ++);//(with the ; at the end of the line)
{
//stuff
}
The Net's most wanted Bugs
Have you ever written a program and had a runtime bug that was almost impossible to notice and was a simple typo? Im starting this thread to help anyone with these notorious fiends that plague our code.
Here are the ones i have experienced:
- Ever get carried away with ; ? Well its legal to write:
and i starts off at 1 not 0.
Debug time - 2 days
- Ever notice how much a 1 looks like an l? Well a fool of a programmer called llvllatrix didnt.
Debug time - 1 week.
- Ever copy and paste code? I did once and forgot to change a 1 to a 2.
Debug time - 1.5 weeks.
Have you ever run into a bug like this? If you have please dial 1-800-999-9999 or post a reply to this thread. Keeping the net clean of the nets most wanted bugs(ominous music) is everyones responsibility.
hehe... Just a couple of days ago I was tracking down a bug that was damn hard to find. I was allocating memory for an array, and I was allocating to little, and when I ran the application it just stopped. I tried to debug it, but VC++ 6.0, adds extra memory around large arrays like that, so I couldn''t find the error when I was debugging! But I eventually found out, after 1 or 2 days, I think.
One thign that I have found is that the most complex bugs are often caused by errors. I now try to compile everything and test it all the time... Before, I would spend 3 hours programming a new class and then debug it. It was impossible to find bugs they componded eachother and made very wierd things happen. Now I''ll program each function one at a time, and test them with some dummy app as I go along. This reduces my debug time a lot.
Also, bugs that are linked to functions that are time independent are VERY hard to debug.... Don''t remember what it was, but I do remember it took like 1 week to find one bug that was related to time...
Dwiel
Also, bugs that are linked to functions that are time independent are VERY hard to debug.... Don''t remember what it was, but I do remember it took like 1 week to find one bug that was related to time...
Dwiel
I don''t do this quite as often nowadays, but a few years ago I used to do these classic beginners mistakes (especially since I emigrated from QBASIC)
Or this one
/John
if (val1 = val2){ //Wonder why this always happens...?}
Or this one
if (val1 == 2);{ //This always happens too...wtf?}
/John
/John
Here's one.
[edited by - Waverider on March 12, 2003 4:57:42 PM]
unsigned char i;for (i=0; i<256; i++){// infinite loop!!???}
[edited by - Waverider on March 12, 2003 4:57:42 PM]
It's not what you're taught, it's what you learn.
How about *iNumber++;
When what you really meant to do is increment the value that iNumber was pointing at, not to increment the pointer...
When I did this, took me a weekend to find the bug, especially because it didn't bomb in debug.
Order of operation..
(*iNumber)++;
[edited by - Ickno on March 12, 2003 8:14:37 PM]
When what you really meant to do is increment the value that iNumber was pointing at, not to increment the pointer...
When I did this, took me a weekend to find the bug, especially because it didn't bomb in debug.
Order of operation..
(*iNumber)++;
[edited by - Ickno on March 12, 2003 8:14:37 PM]
unsigned int i;
for (i=100; i>0; i++) {
// wondered why this never exited
}
The sad thing is, that I make that typo too regularly
-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack
for (i=100; i>0; i++) {
// wondered why this never exited

}
The sad thing is, that I make that typo too regularly

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Something that always trips me up is forgetting to use the new operator e.g
CLog *gameLog; //Normally in a separate header/class
gameLog->Print("Error");
//?WTF is this crashing?
obviously thats simplified I''m not that stupid, but the first time I did it it took me a weekend to solve. Now it takes 5 minutes.
Hyperdev
"To err is human, to really mess up requires a computer"
CLog *gameLog; //Normally in a separate header/class
gameLog->Print("Error");
//?WTF is this crashing?
obviously thats simplified I''m not that stupid, but the first time I did it it took me a weekend to solve. Now it takes 5 minutes.

Hyperdev
"To err is human, to really mess up requires a computer"
"To err is human, to really mess up requires a computer"
My hardest bug was something like this:
I did this because I want to write SU_Log("Value: %d", n);
and macros don''t support variable number of parameters (I think
)
Then I wrote:
When a was 0, SU_LogStoreTemps was not called but SU_LogA was called...
So in the log I found:
main.cpp(00044)::WinMain - ...
but the SU_Log command was in filesystem.cpp
PM
Times change...
Excuse my poor english!
#define SU_Log SU_LogStoreTemps(__FILE__, __LINE__, __FUNCTION__);SU_LogA
I did this because I want to write SU_Log("Value: %d", n);
and macros don''t support variable number of parameters (I think

Then I wrote:
if (a) SU_Log("...");
When a was 0, SU_LogStoreTemps was not called but SU_LogA was called...
So in the log I found:
main.cpp(00044)::WinMain - ...
but the SU_Log command was in filesystem.cpp

PM
Times change...
Excuse my poor english!
PM Times change...
Excuse my poor english!
Hey, let me post again here for a change. A simple mistake I''ll never make again, at a moment i was just not too bright :
What also tends to get me stuck is the difference between an amount of objects, and their reference. For example, the following code :
procedure whatever;var MyClassInstance : TMyClass;begin MyClassInstance.Create; // Heh, calling a constructor doesn''t really work that way // For the non-Delphi programmers, that should have been : MyClassInstance := TMyClass.Create;end;
What also tends to get me stuck is the difference between an amount of objects, and their reference. For example, the following code :
procedure Something;var ADynamicArray : Array of Boolean;var Counter : Byte;begin // The following sets the array to a length of 10 elements SetLength(ADynamicArray, 10); // But I tend to forget that those elements are 0 to 9, not 0 to 10 : for Counter := 0 to 10 do ADynamicArray[Counter] := false;end;
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement