This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++-2.91.34 19980530 : code generation bug on sparc-sun-solaris2.5.1 with -O2
- To: egcs-bugs at cygnus dot com
- Subject: g++-2.91.34 19980530 : code generation bug on sparc-sun-solaris2.5.1 with -O2
- From: Laurent Bonnaud <bonnaud at irisa dot fr>
- Date: 03 Jun 1998 16:00:13 +0200
- Cc: jmotsch at irisa dot fr
Hi,
the following code compiles, but when it is run, it crashes with a "Bus
Error". The program itself has no bugs : it uses no pointers ans has
been checked with purify. The same program runs without crashing, if
it is compiled with -O0, -O1 or -O3 (because the constructor call is
then inlined). It runs well when compiled on i686-pc-linux-gnu with
-O2. I have reduced the code as much as possible, and when i remove
something the program does not crash anymore.
% g++ -O2 bug.cc
% ./a.out
Bus error
--
Laurent.
==================================
class Point
{
public:
Point(double in_U, double in_V)
: U(in_U),V(in_V) {}
double U;
double V;
} ;
class Mvt_aff
{
public:
Mvt_aff(Point Point,
double in_TU, double in_TV,
double in_A11, double in_A12,
double in_A21, double in_A22);
Point Center;
double TU,TV,A11,A12,A21,A22;
} ;
Mvt_aff::Mvt_aff(Point Point, double in_TU, double in_TV,
double in_A11, double in_A12,
double in_A21, double in_A22)
: Center(Point),
TU(in_TU), TV(in_TV), A11(in_A11), A12(in_A12), A21(in_A21), A22(in_A22)
{}
Mvt_aff
COMP(const Mvt_aff& ro_First, const Mvt_aff& ro_Second)
{
Mvt_aff o_Second(Point(0,0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
double A21 = 0.0;
double A22 = o_Second.A21*ro_First.A12;
return Mvt_aff(Point(0,0), 0.0, 0.0, 0.0, 0.0, A21,A22);
}
int main()
{
Mvt_aff M1(Point(0,0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
Mvt_aff M2(Point(0,0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
COMP(M1,M2);
}