Original Post
real big problem :
i have a class which contains a public attribute (float).
for testing purpose, i accessed it from within my main function :
[my classes & code are much bigger... this is only for better understanding...]
class myClass
{
public:
virtual void accessattr();
float attribute;
};
myClass *object = new myClass();
void myClass::accessattr()
{
attribute += 0.01f;
printf ("%5.2f\n", attribute);
}
main()
{
object->attribute += 0.01f;
printf ("%5.2f\n", object->attribute);
object->accessattr();
}
(that''s a VERY short verion of what i did... only the essentials for the bug...)
setting the value of attribute in main(), i noticed that the value of attribute is not the same, as if i were accessing it from within a the member function. that''s weird, isn''t it ?
then i tried the debugger and saw that the compiler produced the following for ''object->attribute+=0.01f'' within main() :
mov ecx,dword ptr [object]
fld dword ptr [ecx+40h]
fadd dword ptr []
mov edx,dword ptr [object]
fstp dword ptr [edx+40h]
...while it produced something like this for the access from within the member function :
mov ecx,dword ptr [this]
fld dword ptr [ecx+18h]
fadd dword ptr []
mov edx,dword ptr [this]
fstp dword ptr [edx+18h]
when i deleted the line in main() and replaced it with the assembler-code & used 18h, instead of 40h, everything worked correctly... !?
so what seems to be the problem ? think, this doesn''t happen in my example... only in bigger classes & projects.
is the MSVC6 compiler buggy ? i''ve often had problems with MSVC-code (especially when compiling .dll files), while the same source compiled in linux/gcc (shared object) worked fine...
i''ve just installed SP5... but that didn''t fix the problem...