VC++ behaves differently when using BreakPoint

F

Faith

Hi all,
I have a serious problem that I am not sure whether its a bug in the
Microsoft Visual C++ or something that I am doing wrong. The problem
is (as noted in the Subject) is that my program behaves differently
when I insert a break point in a certain function (or I step into it)
I get different results. Its the same input and the same code!!
I do not think that adding a source code here will help since its
fairly a long program, but I can say that it includes a bitstream and
I have a function that reads bits from the bitstream and when I add
break points the return value of that function changes!

I will be gratful for any suggestions.
Thanks in advance
Faith

p.s I have tried adding a hard coded breakpoint instread and it still
gave the same results.
 
P

Pete C.

Faith said:
Hi all,
I have a serious problem that I am not sure whether its a bug in the
Microsoft Visual C++ or something that I am doing wrong. The problem
is (as noted in the Subject) is that my program behaves differently
when I insert a break point in a certain function (or I step into it)
I get different results. Its the same input and the same code!!
I do not think that adding a source code here will help since its
fairly a long program, but I can say that it includes a bitstream and
I have a function that reads bits from the bitstream and when I add
break points the return value of that function changes!

I will be gratful for any suggestions.
Thanks in advance
Faith

p.s I have tried adding a hard coded breakpoint instread and it still
gave the same results.

What is this function that you are trying to step through? Perhaps you are
invoking undefined behavior...

- Pete
 
V

Victor Bazarov

Faith said:
I have a serious problem that I am not sure whether its a bug in the
Microsoft Visual C++ or something that I am doing wrong. The problem
is (as noted in the Subject) is that my program behaves differently
when I insert a break point in a certain function (or I step into it)
I get different results. Its the same input and the same code!!
I do not think that adding a source code here will help since its
fairly a long program, but I can say that it includes a bitstream and
I have a function that reads bits from the bitstream and when I add
break points the return value of that function changes!

It seems that your code may be dependent on how fast it's executing.
That's fairly uncommon, but not unheard of. Unfortunately, C++ language
cannot help you here. The C++ virtual machine executes the same program
with the same (and predictable) side effects every time. I recommend
you to post your question to microsoft.public.vc.language and ask there.

Try examining the code your compiler produces. VC++ used to be shakier
than it's now (and you didn't say what version you're using), the code
generator has improved over the years. Sometimes it helps to just add
'volatile' to a variable to force it store the values instead of caching
it in registers (which VC++ v6 seems to get wrong every so rarely).
p.s I have tried adding a hard coded breakpoint instread and it still
gave the same results.

I can't say I understand which results would those be. Perhaps when
you are posting your question to the microsoft newsgroup, you will
revise that statement.

V
 
P

Pete C.

Victor said:
It seems that your code may be dependent on how fast it's executing.
That's fairly uncommon, but not unheard of. Unfortunately, C++
language cannot help you here. The C++ virtual machine executes the
same program with the same (and predictable) side effects every time.
I recommend you to post your question to microsoft.public.vc.language
and ask there.

It may not be a VC++ specific problem; it could be the result of UB. It's
happened to me a few times when I had UB...

- Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top