473,378 Members | 1,478 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,378 software developers and data experts.

breakpoint traps on wrong line (msvc 7.1)

Jay
Guess this has probably been reported already. Seems if you don't use {}
with for/while etc., the debugger stops at the wrong line. In the example
below, I had a breakpoint at line 6 but the debugger stopped in every
iteration of the loop.

Jay

1. for (int index=0; index < line_buffer.Length (); index++)

2. if (line_buffer [index] == '\t')

3. line_buffer [index] = ' ';
4. // }}}

5. //
6. terminator_holding_chars = ""; // <- breakpoint here
Nov 16 '05 #1
4 1731
>Guess this has probably been reported already. Seems if you don't use {}
with for/while etc., the debugger stops at the wrong line. In the example
below, I had a breakpoint at line 6 but the debugger stopped in every
iteration of the loop.


Jay,

Are you debugging a debug or release build of your code?

You should certainly expect strange behaviour debugging a release
(optimised) build.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 16 '05 #2
Jay

"David Lowndes" <da****@mvps.org> wrote in message
news:ou********************************@4ax.com...
Guess this has probably been reported already. Seems if you don't use {}
with for/while etc., the debugger stops at the wrong line. In the example
below, I had a breakpoint at line 6 but the debugger stopped in every
iteration of the loop.


Jay,

Are you debugging a debug or release build of your code?

You should certainly expect strange behaviour debugging a release
(optimised) build.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq


This is definitely the debug configuration. Sure I'd expect an optimizing
compiler to do very peculiar things to the code (I know, I write them :-).
This isn't a serious problem, but I noticed in previous versions, when using
single step the debugger appeared to go to strange places sometimes,
particularly with switch statements. I think what's happening is that the
compiler inserts an extra 'dummy' statement at the end of a for loop so that
you can see the consequences of the last statement

e.g. in

for (;;)
{
bool ok = f (x);
}

you wouldn't be able to see the 'ok' value (with single step) unless there
was some other statement following it.

Now, in the example above, you can put a breakpoint on the '}' which works
fine. The problem is if you don't use {}, the debugger gets confused where
this dummy statement is e.g.

1. for (;;)
2 bool ok = f (x);
3.
4. int a=1;

The debugger *should* recognise that it's ok to put the dummy statement (and
indeed a breakpoint) at line 3 (i.e. at the *end* of line 2) but I guess it
has certain rules that prevent this. So it moves it to line 4. Consequently,
if you really intended to put the breakpoint at line 4, the compiler tests
it for a breakpoint in the loop and traps there by mistake.

Anyway, I don't know how the compiler team have implemented this so I'm
guessing a bit and if you ask them, you might well get the answer it's 'by
design' as it might be quite awkward to change.

Jay


Nov 16 '05 #3
Jay,

You're right.

As a proponent of always putting in the curly brackets, I've never
noticed this myself.

Let's see if someone from MS spots your post and gives us the nitty
gritty, if they don't, I'll try to raise your question with them.

As you say, it's probably "by design", but it's best to be sure.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 16 '05 #4
Yes, this is a known issue, it should be fixed in the Whidbey release. I'll
have someone verify that it is.

Ronald Laeremans
Visual C++ team

"David Lowndes" <da****@mvps.org> wrote in message
news:og********************************@4ax.com...
Jay,

You're right.

As a proponent of always putting in the curly brackets, I've never
noticed this myself.

Let's see if someone from MS spots your post and gives us the nitty
gritty, if they don't, I'll try to raise your question with them.

As you say, it's probably "by design", but it's best to be sure.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq

Nov 16 '05 #5

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

Similar topics

2
by: Panchi51 | last post by:
Hi, Below is a collection of tips/tricks/caveats for LP64 c coding, full text is at http://www.cs.albany.edu/~mosh/Text/c-ref.txt. Hope it helps, corrections welkome. --...
0
by: Frans Bouma | last post by:
Hello, It seems VS.NET 2003 locks up itself and the complete shell (mouse locks also) when entering a breakpoint in a special situation. Below is the code to reproduce this behavior. It...
4
by: Wal Turner | last post by:
Consider the following simple class: public class ClassA { public static string VAR = "hello"; } public void MethodA() { while(true)
3
by: c0uch | last post by:
the first and third methods are in a usercontrol object. txtValue is a TextBox the float.parse in the if statement on line 3 always works fine. the second float.parse in the third method is...
5
by: One Handed Man [ OHM# ] | last post by:
Pressing Button2 does cause the breakpoint shown in Button1's handler to be active the first time. After stopping the program and restarting it it break as soon as you start Button1, Any ideas...
3
by: Chris Stankevitz | last post by:
Hi all, I once had a function in which I could not set a breakpoint. VS VC++ .net 2003 7.1 (native c++) would crash. This particular function had about five arguments. Each argument was an...
0
by: noleander | last post by:
Hi. Ive been using Visual C++ for two years on an application. The application is one solution, containing 10 projects. 9 of the projects build libraries (*.lib). I've been debugging the...
4
by: JohnR | last post by:
I understand the VS2005 still doesn't support data breakpoints in VB. My question is this.. does anybody know of a 3rd party product that DOES support data breakpoints in VB? As an aside, does...
2
by: Jivanmukta | last post by:
Hello, I have a page index.php and a file functions.js. The page index.php conatins:         <script type="text/javascript" src="include/functions.js"> I need to set breakpoint in some...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.