Ray Hagstrom wrote:
ForumVisual C++ / MFC Subject:Re: Release Code Optimization Problems.. Sender:Ray Hagstrom Date:14:46 20 May '06 Sounds a lot like scientific programming.
I'm doing some system verification code, the system guys use Matlab for generating their models, and I run some "C" code to verify their models.
Ray Hagstrom wrote:
1.)Array overrun (Solution: interface array access through an intermediary function that executes a bunch of assert(); to verify that access is always within bounds. The asserts all dissappear in the release mode so that they do not slow production down at all.)
Yes, But this could also happen in the Debug or Release without speed optimization, and it does not happen, the problem arises only when I compile the code with speed optimization (/O2 flag) (PC-Lint[^] did not find any access out of bounds in the code)
Ray Hagstrom wrote:
2.)Optimizer bug. (Here the machine-code generated by the compiler is just flat wrong. Every mature scientific programmer must be prepared to deal with this horrible sort of problem. I have NEVER (since 1965) dealt with a compiler that I did not find bugs in its code generation. Here, my best approach is to start backward from the crash line. Either some datum going into the crash is wrong or the line is encoded wrong.)
The program does not crash, but produces wrong results when compiled with the optimize for speed flag. I'm currently adding some TRACE lines to print out the computed results and then compare them with the Debug (or Release without code optimization).. but that is like looking for a needle in a montain of hay :(( Any additional hint? Thanks to all in advance. :rose: -- **Ricky Marek** (_AKA: rbid_)
-- "Things are only impossible until they are not" --- Jean-Luc Picard My articles