This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/64530] [4.9 Regression] Incorrect calculation when assigning to array with -O3
- From: "anlauf at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 07 Jan 2015 22:36:31 +0000
- Subject: [Bug fortran/64530] [4.9 Regression] Incorrect calculation when assigning to array with -O3
- Auto-submitted: auto-generated
- References: <bug-64530-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64530
Harald Anlauf <anlauf at gmx dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gmx dot de
--- Comment #1 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to jkaus from comment #0)
> With O3 we get the wrong result (0.0):
> gfortran -O3 a.F90
> ./a.out
> > buggy 0.0000000000000000 0.0000000000000000 0.0000000000000000
> > works 3.5000000000000000 3.5000000000000000 3.5000000000000000
Interesting bug. I can confirm that it does not occur with 4.8,
but with 4.9 and 5.
Note that if one interchanges in subroutine "buggy" the lines
old(i) = ave(i)
tmp(i) = tmp(i) / scale_factor
to
tmp(i) = tmp(i) / scale_factor
old(i) = ave(i)
I also get the correct result.
With gfortran 4.9 and 5 I also get the correct result with -O3
when e.g. using UBSAN (-fsanitize=undefined); it probably also
reduces the optimization.
Since the dump tree looks the same for 4.8 and 4.9, could it be
a middle-end bug?