473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Smooth Moves

So I had this bit of strange looking code:

if (led->m_to[i] != prev &&
(FCanCrossSelf || !_hit[led->m_to[i]->m_index]));
{
cango.push_back(i);
}

I was having a problem where it was getting into the if statement even
when the condition was supposed to be false. I could not, for the life
of me, figure out what was going on. The condition has so many braces
and arrows and things in it, and I had been staring at it for so long.
Why was it getting into the if statement when the condition was false?
I could print debugging info from inside the statement and verify it
was false. I could step through in my debugger and watch it step into
the statements, even when it evaluated to false. What was going on?

Well it's obvious when I look at it now, but after *over* an hour of
debugging, looking at conditions, looking at other code, checking for
buffer overruns in strange places, I *finally* spotted the damn extra
semicolon I accidentally typed at the end of the "if". See it? It's
right there before that left curly brace.

I slapped myself on the head pretty hard after realizing how dumb the
mistake was. It's not the first time I've spent a long time debugging
a simple syntax mistake like that.

So now, I am taking a break for a few minutes, and I am wondering:
what kinds of horror stories do people here have about silly mistakes
like this one? Hours spent debugging when you typed a j instead of an
i, or put a parenthesis in the wrong spot, an extra semicolon, a
problematic #define. There's got to be some good stories out there!

- AJ
Mar 3 '08 #1
1 1550
ad*******@gmail.com wrote in news:fa29c801-70d1-40b4-a965-cb8d79379426@
59g2000hsb.googlegroups.com:
So now, I am taking a break for a few minutes, and I am wondering:
what kinds of horror stories do people here have about silly mistakes
I think one of the best was when I accidentally entered íf instead of if.
After getting some spurious errors I spent a lot of time checking the
braces, the previous statements, semicolons etc. It never occured to me
to look at the if word itself. However, finally I noticed that the syntax
coloring had failed to color it...

And just today I copy-pasted a little function from one file to another,
and it stopped compiling, complaining that T is not a type name:

/// Cast from signed integer pointer to unsigned integer pointer or back
template<typename T, typename U>
T sign_cast(U p) {
// .. some checks
return reinterpret_cast<T>(p);
}

Fortunately I have the habit to (nervously?) move around in the text by
arrow keys when thinking, and I noticed that when going up or down in the
text the "template" line is jumped over. It appeared that copy-pasting
into text-mode emacs window somehow managed to screw up the linebreak
before the "template" line - probably replaced by CR, so that everything
looks OK on the screen, but the compiler thought template line was just a
continuation of the comment...

Regards
Paavo
Mar 6 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Geoff Jones | last post by:
Hi I have been using a smooth progress control using the following link: http://support.microsoft.com/default.aspx?scid=kb;en-us;323088#2 It works well, however I can't seem to get it to...
4
by: petermichaux | last post by:
Hi, Is there any way to make DOM scripted animation smoother? Flash is far superior in this area. Any one here know what makes Flash so smooth by comparison? I don't like the fact that the...
0
by: zootmelk | last post by:
Hi, I would like to know how to deactivate the Smooth Roaming feature under Citrix PS4 for both Web interface AND Program Neighbourhood connection. Indeed, my users works with 2 computers (4...
0
by: evan | last post by:
Hi, Pleeeeeaaaassseee help. I have spent literally days looking for a solution to this problem but cannot find the solution. Does anyone know how to smooth scroll a listbox? I can scroll using...
3
by: Richard Lewis Haggard | last post by:
I have an unbound DataGridView control that has some cells that may contain more multi-line text than can be completely displayed in the available screen space. When the height of its row to...
1
by: Bishman | last post by:
Hi, I have been trying to get text to scroll smoothly accross a windows form using GDI+ and a timer. Changing the position of the text by a configurable amount and calling invalidate to force a...
7
by: active | last post by:
In control panel/Display/Appearance/Effects if : 'Use the following method to smooth edges of screen fonts' is checked and ClearType is selected in the combobox (no problem if Standard is...
1
by: tromton | last post by:
heello, i havee one div element in my site with several anchors, that i link to. to change from anchor to another id like to have a smooth scrolling effect. all the smooth scrolling effects i...
1
by: saritbhatta | last post by:
hi all, I am trying to create a single drop down menu with submenu with smooth drop down effect using javascript,css and html. I am getting many examples but without any smooth effect. Can...
18
by: Bert | last post by:
This is a past question from a programming competition. On a chess board (8 squares by 8 squares), there's is a knight sitting on b1 (2 from the left of the bottom row). To cut the crap, find out...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.