-
August 29th, 2012, 02:44 AM
#1
Strangest bug ever!
Alright, here is my piece of code :
Code:
long *a = &(cgm.o->m_metafileVersion);
I put a break point at the following instruction and when I look in the watch section of visual C++ 2010, I have that :
a = 0x053e3d50
&(cgm.o->m_metafileVersion) = 0x053e3d28
weird, isn't it?
-
August 29th, 2012, 02:57 AM
#2
Re: Strangest bug ever!
Why?
Victor Nijegorodov
-
August 29th, 2012, 03:29 AM
#3
Re: Strangest bug ever!
Why it is weird?
because "a" is a pointer and it get the adresse of cgm.o->m_metafileVersion.... so unless I woke up in a parallel world, where the C++ rules would be different, "long *a" should be equal to "&(cgm.o->m_metafileVersion)"... and it's not (!!!)
-
August 29th, 2012, 03:37 AM
#4
Re: Strangest bug ever!
When did you look in the watch section: before or after this line had been executed?
Victor Nijegorodov
-
August 29th, 2012, 03:47 AM
#5
Re: Strangest bug ever!
after! I put a break point at the following instruction.
-
August 29th, 2012, 04:42 AM
#6
Re: Strangest bug ever!
yeah I know it's weird... but I don't even know, who can I speak to to get help...
-
August 29th, 2012, 06:47 AM
#7
Re: Strangest bug ever!
Originally Posted by ArnaudCas
yeah I know it's weird... but I don't even know, who can I speak to to get help...
I did a very simple test:
Code:
class CTest
{
public:
long m_metafileVersion;
CTest() {m_metafileVersion = 0;}
};
class CGm
{
public:
CTest o;
int something;
CGm() {something = 0;}
};
CGm cgm;
long *a = &(cgm.o.m_metafileVersion);
What I see in the watch window is:
Code:
&(cgm.o.m_metafileVersion) 0x0012f4a8 long *
a 0x0012f4a8 long *
The only difference I see is: I use the object o while you use some pointer o.
Where does it point to?
Victor Nijegorodov
-
August 29th, 2012, 07:12 AM
#8
Re: Strangest bug ever!
errh, the object "o" points to a data structure, a class, from the library I use (it's a lib to read cgm files)
Do you think the lib has a problem? or my EDI (Visual Studio)?
-
August 29th, 2012, 07:29 AM
#9
Re: Strangest bug ever!
I don't know.
I tested in
Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.0.30319 SP1Rel
Installed Version: Ultimate
....
Microsoft Visual C++ 2010 01019-532-2002102-70738
Microsoft Visual C++ 2010
....
Hotfix for Microsoft Visual Studio 2010 Ultimate - ENU (KB2548139) KB2548139
This hotfix is for Microsoft Visual Studio 2010 Ultimate - ENU.
If you later install a more recent service pack, this hotfix will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/2548139.
Hotfix for Microsoft Visual Studio 2010 Ultimate - ENU (KB2565057) KB2565057
This hotfix is for Microsoft Visual Studio 2010 Ultimate - ENU.
If you later install a more recent service pack, this hotfix will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/2565057.
Microsoft Visual Studio 2010 SharePoint Developer Tools 10.0.40219
Microsoft Visual Studio 2010 SharePoint Developer Tools
Microsoft Visual Studio 2010 Ultimate - ENU Service Pack 1 (KB983509) KB983509
This service pack is for Microsoft Visual Studio 2010 Ultimate - ENU.
If you later install a more recent service pack, this service pack will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/983509.
Security Update for Visual Studio 2010 Shell (Isolated) - ENU (KB2644980) KB2644980
This security update is for Visual Studio 2010 Shell (Isolated) - ENU.
If you later install a more recent service pack, this security update will be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/2644980.
Victor Nijegorodov
-
August 29th, 2012, 07:43 AM
#10
Re: Strangest bug ever!
I dont see what I have to do with your links.
I tested the lib in a new simple main program, and I have the error too. So Maybe it comes from the lib, but how? The error seems to come from the IDE, nevertheless, right?
-
August 29th, 2012, 07:57 AM
#11
Re: Strangest bug ever!
Originally Posted by ArnaudCas
I dont see what I have to do with your links.
Just compare it with your VS2010 installation data.
Originally Posted by ArnaudCas
I tested the lib in a new simple main program, and I have the error too. So Maybe it comes from the lib, but how? The error seems to come from the IDE, nevertheless, right?
I don't know, sorry.
Victor Nijegorodov
-
August 29th, 2012, 08:20 AM
#12
Re: Strangest bug ever!
Originally Posted by ArnaudCas
The error seems to come from the IDE, nevertheless, right?
what error ? we can have no idea if it is a program bug ( highly plausible ), a compiler bug ( highly unplausible ) or a debugger glitch by just looking at a single line of apparently correct code.
BTW, note that this forum is for visual studio bugs, not yours. As said above, it's highly implausible that the compiler breaks such a basic statement. It's highly plausible that you made a mistake somewhere in your program that reproduces the observed behavior, or that you're improperly using the debugger.
Now, to exclude the possibility of a debugger viewer bug, place an "_ASSERT( a == &(cgm.o->m_metafileVersion) );" at the break point. If this gives a runtime error, ask a moderator to move the thread to the Visual C++ Programming forum; then, post the smallest but complete piece of code capable of reproducing the problem.
-
August 29th, 2012, 10:15 AM
#13
Re: Strangest bug ever!
I tried and there is no runtime error.
as I told you,
Code:
long *l = &(cgm.o->m_metafileVersion);
doesn't work as it should be, that's why I try to find help here. I don't understand.
I've got a class with a pointer to an object from the lib I use to read CGM files :
Code:
class CGM
{
public:
CCgmObjects *o;
public :
CGM():o(NULL){}
~CGM(){if(o)delete o;}
int load(const char* pFilename);
};
I load it with that function :
Code:
int CGM::load(const char* pFilename){
CConfig *pConfig = new CConfig();
if (pConfig != 0)
{
// create a CgmObjects instance and Load the CGM file
o = new CCgmObjects(pConfig, NULL);
if (o != 0)
{
std::string userFontsDir = ".";
// Load the CGM file
error = o->LoadFile(pFilename);
if (error != 0)
{
printf("cannot open the file");
}
}
}
but, again, it's not a programing problem. It's like if it is a Visual C++'s bug. The visual installation seems to be good...
Maybe there is a param or something in the project configuration?
-
August 29th, 2012, 10:28 AM
#14
Re: Strangest bug ever!
Originally Posted by ArnaudCas
Code:
long *l = &(cgm.o->m_metafileVersion);
doesn't work as it should be, that's why I try to find help here. I don't understand.
- How should it work and how does it work?
- Your code snippet does not contain the line you referred to.
- Did you try with ASSERT as superbonzo suggested?
Victor Nijegorodov
-
August 29th, 2012, 11:30 AM
#15
Re: Strangest bug ever!
How should it work and how does it work?
Ok if I write :
Code:
long *l = &(cgm.o->m_metafileVersion);
it should be :
a = 0x053e3d28
&(cgm.o->m_metafileVersion) = 0x053e3d28
but it is :
a = 0x053e3d50
&(cgm.o->m_metafileVersion) = 0x053e3d28
Your code snippet does not contain the line you referred to.
Yes you are right, sorry for that. The line is in the main, just after the call of the load method.
something like :
Code:
int main(){
CGM cgm;
cgm.load("C:/myCGM.cgm");
long *a = &(cgm.o->m_metafileVersion);
_ASSERT( a == &(cgm.o->m_metafileVersion) );
}
Did you try with ASSERT as superbonzo suggested?
Yes I did!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|