I have a problem with some code I have written. This code basically tests that a string class/library I have created works. This class overrides various operators and a seperate prject tests it. Everything works fine in a debug build. However when I perform a Retail build the code in the testing module compiles but when I run the testing code it informs me that my class is broken. I checked the assembely listing output and it has skipped assembling pieces of my source code. Example of disassembely follows from testing module (not the string class which works fine)
As you can see no assembely code was generated for the bool assignments. Later the values are assigned true or false depending on the result of various comparision operators.
The comparisons as well as the assignment code are completely skipped in the debugger. All this can not be due to the fact that the compiler is not generating debugging information since the actual output of the test program is affected.
My theory as to whats happened is the compiler thinks these bool values are not used within the function and as removes references to them as it thinks they are not needed (An optimization option in visual c++). However it should relize that the values are referenced because one of the final lines is
Anyway any hints as to what you think is going on would be much appreciated. By the way I am using Visual Studio .NET without any managed code.
Code:
bool PerformNotEqualTest()
{
push ebp
lea ebp,[esp-78h]
sub esp,13Ch
push ebx
push esi
//Function Prefix code above my code starts from here
bool Test1=false;
bool Test2=false;
bool Test3=false;
bool Test4=false;
CUniString String1=TEXT("This is the first string...");
push 4088BCh
lea eax,[ebp-5Ch]
call 0040120E
CUniString String2=TEXT("This is the second string...");
push 408880h
lea eax,[ebp+FFFFFF3Ch]
call 0040120E
CUniString String3=TEXT("This is the third string...");
mov esi,408848h
push esi
lea eax,[ebp+0Ch]
call 0040120E
//Code Continues...
The comparisons as well as the assignment code are completely skipped in the debugger. All this can not be due to the fact that the compiler is not generating debugging information since the actual output of the test program is affected.
My theory as to whats happened is the compiler thinks these bool values are not used within the function and as removes references to them as it thinks they are not needed (An optimization option in visual c++). However it should relize that the values are referenced because one of the final lines is
Code:
if((Test1)&&(Test2)&&(Test3))
return true;
Anyway any hints as to what you think is going on would be much appreciated. By the way I am using Visual Studio .NET without any managed code.