This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/54498] [4.7/4.8 Regression] incorrect code generation from g++ -O
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 05 Sep 2012 22:21:58 +0000
- Subject: [Bug tree-optimization/54498] [4.7/4.8 Regression] incorrect code generation from g++ -O
- Auto-submitted: auto-generated
- References: <bug-54498-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54498
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |wrong-code
Last reconfirmed| |2012-09-05
Component|c++ |tree-optimization
Ever Confirmed|0 |1
Summary|incorrect code generation |[4.7/4.8 Regression]
|from g++ -O on x86_64 |incorrect code generation
| |from g++ -O
Target Milestone|--- |4.7.2
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-09-05 22:21:58 UTC ---
Confirmed, here is the source unincluded:
#include <complex>
#include <cstdio>
using namespace std;
class bar_src {
public:
bar_src() : next(0) {}
virtual ~bar_src() { delete next; }
bar_src *next;
};
class foo_src : public bar_src {
public:
foo_src(double f, double fwidth, double s = 5.0);
virtual ~foo_src() {}
private:
double freq, width, peak_time, cutoff;
};
foo_src::foo_src(double f, double fwidth, double s) {
freq = f; width = 1/fwidth; cutoff = s*width; peak_time = cutoff;
}
complex<double> do_ft2(int i) __attribute__ ((noinline));
complex<double> do_ft2(int i) {
return i == 0 ? complex<double>(-491.697,887.05) :
complex<double>(-491.692,887.026);
}
void foo(void) {
complex<double> prev_ft = 0.0, ft = 0.0;
for (int i=0; i < 2; i++) {
prev_ft = ft;
{
foo_src src(1.0, 1.0 / 20);
ft = do_ft2(i);
printf("ft (it = %d) = %g%+gi\n", i, real(ft), imag(ft));
}
if (i > 0)
printf("abs(ft - prev_ft) = %g\n",
abs(ft - prev_ft));
}
}
int main(void) {
foo();
return 0;
}
--- CUT ---
The problem comes from FRE, I think due to how it handles look though copies.
It happens on more than just x86_64.