This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/34841] 'make check' of libsndfile-1.0.17 fails with gcc-4.2.2 -O2 optimization, OK with -O1 one
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jan 2008 09:47:52 -0000
- Subject: [Bug c/34841] 'make check' of libsndfile-1.0.17 fails with gcc-4.2.2 -O2 optimization, OK with -O1 one
- References: <bug-34841-13529@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #14 from manu at gcc dot gnu dot org 2008-01-18 09:47 -------
(In reply to comment #12)
>
> - I do not think this is fine. As end user I want to see my errors the same
> way at any optimization level.
>
We strive to for this when it is feasible and reasonable, but there is a
trade-off between functionality and compilation speed. Detecting some errors
requires analyzing the code and performing transformations. This is precisely
what optimisations do. The higher the optimisation level, the deeper the
analysis and the larger the transformations. Doing the maximum analysis and
transformations at -O0 and throwing away the results would be pointless. Would
you like if -O0 were to take more time than -O3? Most users won't.
> My expectations are that regardless of optimization level I'll get my program
> functioning the same way, but with different memory consumption/speed.
If you believe this, you are going to be deeply disappointed by reality. Apart
from the unavoidable fact that bugs in the code (like in this case), race
conditions and hardware problems may be more evident with one optimisation or
another, there are issues with floating point precision (PR323) and others.
> I am not talking about out of bounds indices and possible reshuffling of
> variables in memory, I'm talking about arithmetic/logic expressions, i.e.
>
> printf("some_var=%g\n", some_var);
>
> should always print the same.
>
That can't be the case always. Arithmetic/logic expressions have precision
errors that are different depending on the order of operations. And altering
the order of operations is precisely what you are asking when you enable
optimizations. Anyway, this is not the place for such theoretical discussion
If "gcc -O2 -Wstrict-overflow=5" does not give a warning, we may have a bug (or
it may be a case too difficult to detect). Could you try that, please?
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34841