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

" i = 10 " gives " i == 6 " ?!?!?!

Hello,

I'm a software engineer for a Dutch company and I am
working on the improvement of a already made program and
I've found a very curious problem. It consists of two
parts, explained below:

When one of my functions is called, the program works as
it is supposed to do, but when I add a line, say for
example:
int i;
i = 10;
or something like that, the progam stops executing the
function before it reaches the end of its code. The more
lines of code I put in the function, the earlier the
function is stopped.

Almost stranger is the fact that when I place the code
above (int i; i = 10;) in the code and I use a debugger to
view the process, I can see the value of 'i' change from
i = 835xxxxxx at function start to
i = 12xxxxx somewhere in the function (where 'i' is not
called) to
i = 6 after the line 'i = 10;'

I myself truly haven't got a clue why this should happen.
Anybody who can help?

With kind regards,

Maarten

Nov 15 '05 #1
8 1386
Hi,

Sounds like you're either debugging a release (and optimized) build, or the
source code you're debugging isn't the code that's running. Have you tried
deleting the build, then completely rebuilding a debug build? I'd be
suspicious, if you got the program from somewhere else, that there're some
dependencies that are wrong and so it's not compiling or linking the code
you're changing.

Thanks,

Steve

"Maarten" <an*******@discussions.microsoft.com> wrote in message
news:47****************************@phx.gbl...
Hello,

I'm a software engineer for a Dutch company and I am
working on the improvement of a already made program and
I've found a very curious problem. It consists of two
parts, explained below:

When one of my functions is called, the program works as
it is supposed to do, but when I add a line, say for
example:
int i;
i = 10;
or something like that, the progam stops executing the
function before it reaches the end of its code. The more
lines of code I put in the function, the earlier the
function is stopped.

Almost stranger is the fact that when I place the code
above (int i; i = 10;) in the code and I use a debugger to
view the process, I can see the value of 'i' change from
i = 835xxxxxx at function start to
i = 12xxxxx somewhere in the function (where 'i' is not
called) to
i = 6 after the line 'i = 10;'

I myself truly haven't got a clue why this should happen.
Anybody who can help?

With kind regards,

Maarten

Nov 15 '05 #2
Do you see this behaviour only while you are stepping through in debug mode?

If yes, you could try to delete the .ncb file and recompile your project

José
"Maarten" <an*******@discussions.microsoft.com> wrote in message
news:47****************************@phx.gbl...
Hello,

I'm a software engineer for a Dutch company and I am
working on the improvement of a already made program and
I've found a very curious problem. It consists of two
parts, explained below:

When one of my functions is called, the program works as
it is supposed to do, but when I add a line, say for
example:
int i;
i = 10;
or something like that, the progam stops executing the
function before it reaches the end of its code. The more
lines of code I put in the function, the earlier the
function is stopped.

Almost stranger is the fact that when I place the code
above (int i; i = 10;) in the code and I use a debugger to
view the process, I can see the value of 'i' change from
i = 835xxxxxx at function start to
i = 12xxxxx somewhere in the function (where 'i' is not
called) to
i = 6 after the line 'i = 10;'

I myself truly haven't got a clue why this should happen.
Anybody who can help?

With kind regards,

Maarten

Nov 15 '05 #3
Maarten <an*******@discussions.microsoft.com> wrote:
I'm a software engineer for a Dutch company and I am
working on the improvement of a already made program and
I've found a very curious problem. It consists of two
parts, explained below:

When one of my functions is called, the program works as
it is supposed to do, but when I add a line, say for
example:
int i;
i = 10;
or something like that, the progam stops executing the
function before it reaches the end of its code. The more
lines of code I put in the function, the earlier the
function is stopped.

Almost stranger is the fact that when I place the code
above (int i; i = 10;) in the code and I use a debugger to
view the process, I can see the value of 'i' change from
i = 835xxxxxx at function start to
i = 12xxxxx somewhere in the function (where 'i' is not
called) to
i = 6 after the line 'i = 10;'

I myself truly haven't got a clue why this should happen.
Anybody who can help?


Both of these point to the same cause: the compiled code you're running
isn't generated from the source code you're debugging. Check for any
deployment errors, try wiping old versions from the system etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4
So the problem lays with the debugger not usign the actual correct symbols
yet you encourage hiding the problem.

If the debugger is showing incorrect code with whats running in memory, any
reasonable person can see the bug is the debugger.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Maarten <an*******@discussions.microsoft.com> wrote:
I'm a software engineer for a Dutch company and I am
working on the improvement of a already made program and
I've found a very curious problem. It consists of two
parts, explained below:

When one of my functions is called, the program works as
it is supposed to do, but when I add a line, say for
example:
int i;
i = 10;
or something like that, the progam stops executing the
function before it reaches the end of its code. The more
lines of code I put in the function, the earlier the
function is stopped.

Almost stranger is the fact that when I place the code
above (int i; i = 10;) in the code and I use a debugger to
view the process, I can see the value of 'i' change from
i = 835xxxxxx at function start to
i = 12xxxxx somewhere in the function (where 'i' is not
called) to
i = 6 after the line 'i = 10;'

I myself truly haven't got a clue why this should happen.
Anybody who can help?


Both of these point to the same cause: the compiled code you're running
isn't generated from the source code you're debugging. Check for any
deployment errors, try wiping old versions from the system etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #5
<<.>> wrote:
So the problem lays with the debugger not usign the actual correct symbols
yet you encourage hiding the problem.
I'm not encouraging hiding the problem - I'm encouraging sorting the
problem out, at least in the short term, so that the OP can get on with
coding.
If the debugger is showing incorrect code with whats running in memory, any
reasonable person can see the bug is the debugger.


It's certainly a problem in the debugger or build tool (or possibly
file format for debug information, if it doesn't contain enough
information to verify that the code being executed is actually the code
that the debug information has been generated for). However, knowing
that isn't likely to help the OP. Knowing how to get back to a working
system *is* likely to help them.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #6
Thank you all for your help and early replies.
I believe that the problem is indeed, as some have said,
that the code that is running isn't the code that I'm
viewing/editing. To solve this, I've tried a few things:

I've tried deleting some old versions, but this didn't
help.
I've used the 'clean' function in Visual C++ to delete al
the build files, but this didn't help either.
I've removed al the .cpp, .h and recource-files form the
project and added the ones I wanted to use from the right
directory. This was ok, but for 2 files. These were the
files 'StdAfx.cpp' and 'StdAfx.h'. I believe that they are
generated by MSVisualStudio. But removing and adding the
other files didn't solve my problem.

Does anybody have any idea what else I can try?

Best regards,
Maarten Veldink

-----Original Message-----
Maarten <an*******@discussions.microsoft.com> wrote:
I'm a software engineer for a Dutch company and I am
working on the improvement of a already made program and I've found a very curious problem. It consists of two
parts, explained below:

When one of my functions is called, the program works as it is supposed to do, but when I add a line, say for
example:
int i;
i = 10;
or something like that, the progam stops executing the
function before it reaches the end of its code. The more lines of code I put in the function, the earlier the
function is stopped.

Almost stranger is the fact that when I place the code
above (int i; i = 10;) in the code and I use a debugger to view the process, I can see the value of 'i' change from
i = 835xxxxxx at function start to
i = 12xxxxx somewhere in the function (where 'i' is not called) to
i = 6 after the line 'i = 10;'

I myself truly haven't got a clue why this should happen. Anybody who can help?
Both of these point to the same cause: the compiled code

you're runningisn't generated from the source code you're debugging. Check for anydeployment errors, try wiping old versions from the system etc.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

Nov 15 '05 #7
Maarten Veldink <ma*************@home.nl> wrote:
Thank you all for your help and early replies.
I believe that the problem is indeed, as some have said,
that the code that is running isn't the code that I'm
viewing/editing. To solve this, I've tried a few things:

I've tried deleting some old versions, but this didn't
help.
That means you just haven't deleted the *right* old version :)

I suggest you get a process viewer which can show you exactly which
process is being run, and delete that one, then do a clean build.

The process viewer I use is from www.prcview.com.
I've used the 'clean' function in Visual C++ to delete al
the build files, but this didn't help either.
I've removed al the .cpp, .h and recource-files form the
project and added the ones I wanted to use from the right
directory. This was ok, but for 2 files. These were the
files 'StdAfx.cpp' and 'StdAfx.h'. I believe that they are
generated by MSVisualStudio. But removing and adding the
other files didn't solve my problem.

Does anybody have any idea what else I can try?


No, but then this doesn't sound like a very C#-related question - I
suggest you try on the managed C++ group.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #8
Hello, Maarten!

In such case I usually just create a brand new project
and then replace the sourcecode of the new project
with the one I want to work with...

Hope that helps.

You wrote on Mon, 1 Mar 2004 03:08:30 -0800:

M> I'm a software engineer for a Dutch company and I am
M> working on the improvement of a already made program and
M> I've found a very curious problem. It consists of two
M> parts, explained below:

M> When one of my functions is called, the program works as
M> it is supposed to do, but when I add a line, say for
M> example:
M> int i;
M> i = 10;
M> or something like that, the progam stops executing the
M> function before it reaches the end of its code. The more
M> lines of code I put in the function, the earlier the
M> function is stopped.

M> Almost stranger is the fact that when I place the code
M> above (int i; i = 10;) in the code and I use a debugger to
M> view the process, I can see the value of 'i' change from
M> i = 835xxxxxx at function start to
M> i = 12xxxxx somewhere in the function (where 'i' is not
M> called) to
M> i = 6 after the line 'i = 10;'

M> I myself truly haven't got a clue why this should happen.
M> Anybody who can help?

M> With kind regards,
With best regards, Nurchi BECHED.
Nov 16 '05 #9

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

Similar topics

0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
4
by: kaeli | last post by:
All, I've been unable to find out if javascript supports for (var e in obj) type of looping syntax. Does it? If so, is this for DOM browsers only? TIA! --
4
by: Jian H. Li | last post by:
Hello, What's the essential differences between the two ways of "class::member" & "object.member"(or object_pointer->member)? class C{ public: void f() {} int i; };
6
by: Matthew | last post by:
How would I go about creating a simple "hello world" program that will run in Unix. I am using MS Visual C++.
0
by: antsays | last post by:
I am trying to serialize a collection to disk using the code provided. This works just fine but when I try do copy and past the xml file to another location or sometimes even just click on the...
5
by: z. f. | last post by:
sorry about the previous post, by mistake not completed. i have an asp.net page with the line <%@ OutputCache Duration="30" VaryByParam="none" %> but when i make requests to the page with...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
7
by: lukertin | last post by:
I have a 2-D array stored as an object, when i go to call up the array using my $testvar = @ {$self->Peptides}; it gives me the error Can't use string ("0") as an ARRAY ref while "strict...
4
by: lostlander | last post by:
In ARMCC, and Microsoft C, when i use a function which is never defined or delared, it gives out a warning, not a compiling error? why? (This leads to a bug to my program since I seldom pay much...
24
by: Jeremy J Starcher | last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even recommend the use of "window.alert()" over "alert()". I can't find any technical reason to make this distinction, and...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.