Problem with Optimize for speed in VC++ 5.0 
Author Message
 Problem with Optimize for speed in VC++ 5.0

When 5.0 initially was release I saw a number of optimization problem
dealing with doubles. We still use 4.2b here. But anyway, have you
installed the VC 5.0 service pack 2? This might help...

Good Luck!
--
Steve
Remove NOSPAM from reply address



Quote:
> QUESTION: Does anyone know of bugs in using "optimize for speed" with
> VC++ 5.0, especially involving math functions?

<snip>


Sat, 11 Mar 2000 03:00:00 GMT  
 Problem with Optimize for speed in VC++ 5.0

QUESTION: Does anyone know of bugs in using "optimize for speed" with
VC++ 5.0, especially involving math functions?

SUMMARY: I have bug that appears only when running a Release DLL with
optimize set to "for speed".  There is no problem with the Debug DLL or
when optimization is set to "normal".  The problem did not appear in
VC++ 4.2.  It only presented itself when I recompiled in VC++ 5.0. The
problem is centered around a math calculation that produces the
wrong result.  No underflow or overflow should be happening since I see
the values that are being used.  

I isolated the problem to one line of code that involves a call to
pow().  
Here it is:
        massTransferCoefficient =
                molarMassVelocity * massTransferFactor/                                                                                        
pow(schmidtNumberD/airDiffusivity, 0.667);

I suspected that the program was using some unitialized memory or is
trashing memory, but MemCheck by StratosWare Corp failed to flag
a problem, and the code around the problem area doesn't use pointers
or arrays; it just does a bunch of math calculations.

As part of debugging the problem, I printed
out the variables, and they are all correct.  But the result from the
calculataion is off by a factor of about 100 or so.

The problem goes away if I recompile
with optimize set to "normal" instead of "for speed".  But listen
to this: the problem also goes away if I add extra print statements
immediately before the errant calculation.  That is, adding simple
statements like the one below cause the problem to go away!
    outfile << "value of molarMassVelocity is "
            << molarMassVelocity << endl;



Sat, 11 Mar 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VC++ 5.0 Maximum Speed Optimization Problem

2. VC++ 5.0 Maximum Speed Optimization Problem

3. Problems with for speed optimized code

4. Problems with for speed optimized code

5. vc++ 5.0 to vc++ 6.0 problem

6. VC 5.0 Speed and SMP

7. Problem calling DLL writen in VC 5.0 from VB 5.0

8. Problem calling DLL writen in VC 5.0 from VB 5.0

9. Problem with VSS 5.0 integration with VC++ 5.0

10. Problem calling DLL writen in VC 5.0 from VB 5.0

11. Problem calling DLL writen in VC 5.0 from VB 5.0

12. Problem calling DLL writen in VC 5.0 from VB 5.0

 

 
Powered by phpBB® Forum Software