VC7 optimization? 
Author Message
 VC7 optimization?

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.

Thanks.



Sun, 20 Feb 2005 23:49:33 GMT  
 VC7 optimization?


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.

Usually when I suspect optimization errors, I try to track down at least one
instance where the optimization has gone wrong. If it's just in one place,
you can use an optimization pragma to disable (or reduce) optimizations for
that one section of code. If the case you find points to a larger more
pervasive problem (e.g. some funkiness with floating point), then you can
play with individual optimization settings until that problem goes away.

Either way, if you have the time (no pressing deadlines), I would recommend
trying to verify exactly what is happening to make sure you have fixed the
problem with the optimization setting change (or, at least, put it on your
"todo list" for the next release).

Jay



Mon, 21 Feb 2005 00:05:32 GMT  
 VC7 optimization?

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.



Mon, 21 Feb 2005 04:38:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VC7 optimization question

2. Poor Optimization in VC7.1

3. optimization settings in vc7

4. floating point optimizations in vc7/7.1

5. Difference between code optimization and compiler optimization?

6. possible bug in VC6, VC7, VC7.1

7. Possible bug in vc7.0 (and vc7.1)

8. VS.NET /O2 optimization buggy?

9. Named Return Value Optimization

10. Strange Code Optimization

11. VC++ 7 EA optimization bug!?

12. C/C++ - missing trivial optimization

 

 
Powered by phpBB® Forum Software