Quote:
> After switching from VC6 to VC7 we are having problems
> that we can not relate to our code after days of code
> review and with a help of Purify. ("out of memory"
> exception inside DAO, ...). These problems disappear if I
> change the optimization options from /O2 to /O1 but I am
> not sure that this does not bring us other problems. I
> don't want to switch back to VC6 but our application deals
> with money and need to be bullet proof.
> Are there "safe" optimization options or should I disable
> the optimization completely or should I switch back to VC6?
> P.S. Our system installed at hundreds of locations, runs
> 24x7 and never had such problems when compiled with VC6.
You are mistaken if you think that VC6 doesn't also use what could be
considered "unsafe optimizations". In reality, optimizers must make
assumptions about code, which aren't always true. While there may be a bug
in the VC7's optimizer that's biting you, 9 times out of 10 I find that the
problem is either a subtle bug in the code, or simply code that is contrary
to the assumptions made by the optimizer. It's nice that you never had a
problem with VC6's optimizer, but many people have. Going back to VC6 is no
guarantee that you won't run into a similar problem.
Your best bet is to either disable the optimizations around the offending
code (using a #pragma), disable optimizations all together, or find out why
the problem is happening and alter your code (often times it's just a matter
of re-ordering your code or adding a keyword like "volatile").
A common problem when moving to a new compiler is that the new compiler lays
out memory differently than the old one, this allows a subtle bug which may
have gone unnoticed out of sheer luck before to become visible. I know you
say you're using Purify and done code reviews, but that doesn't mean it
hasn't been missed.