Blitz logo

Blitz Bugs :

From: Sylvain Barbay (sylvain.barbay_at_[hidden])
Date: 2002-09-13 07:39:22


When I compile a simple code (see at the end of the text) with g++
[gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)]

using

g++ -ftemplate-depth-30 -O -g -lblitz -o toto -L ~/blitz/lib -I ~/blitz
toto.cc

I get the correct output :

2 x 2
[ ( 2,0) ( 2,0)
   ( 2,0) ( 2,0) ]
2 x 2
[ ( 0,0) ( 0,0)
   ( 0,0) ( 0,0) ]
2 x 2
[ 1 1
           1 1 ]

2 x 2
[ ( 2,0) ( 2,0)
   ( 2,0) ( 2,0) ]

2 x 2
[ ( 1,0) ( 1,0)
   ( 1,0) ( 1,0) ]

2 x 2
[ ( 2,2) ( 2,2)
   ( 2,2) ( 2,2) ]

2 x 2
[ ( 5,2) ( 5,2)
   ( 5,2) ( 5,2) ]

However when I use -O2 or -O3 I get :

2 x 2
[ ( 2,0) ( 2,0)
   ( 2,0) ( 2,0) ]
2 x 2
[ ( 0,0) ( 0,0)
   ( 0,0) ( 0,0) ]
2 x 2
[ 1 1
           1 1 ]

2 x 2
[ ( 2,0) ( 2,0)
   ( 2,0) ( 2,0) ]

2 x 2
[ ( 1,0) ( 1,0)
   ( 1,0) ( 1,0) ]

2 x 2
[ ( 2,2) ( 2,2)
   ( 2,2) ( 2,2) ]

2 x 2
[ ( 5,6.19379e-313) ( 5,6.19379e-313)
   ( 5,6.19379e-313) ( 5,6.19379e-313) ]

The last line is obviously wrong. Why is it so ???????
Is it related to g++ or to blitz ?

I join a sample code that reproduces the bug at the end.

Thanks in advance,

Sylvain.

toto.cc :
*****************************************
#include <iostream>
#include <math.h>

#include <blitz/array.h>

using namespace blitz;

main()

{

  Array<complex<double>,2> A(2,2), B(2,2);
  Array<double,2> C(2,2), D(2,2);
  complex<double> p1, p2;
  double p3;

  A = complex<double>(2.0,0.0);
  C=1.0;

  cout << A << B << C << endl;

  p1 = complex<double>(1.0,0);
  p2 = complex<double>(1.0,1.0);
  p3 = 3.0;

B = p1*A;

  cout << B << endl;

B = p1*(C-0.5)*A;

  cout << B << endl;

B = p2*A;

  cout << B << endl;

B = p1*A + p1*(C-0.5)*A + p2*A;

  cout << B << endl;

}
*****************************

_______________________________________________
Blitz-bugs mailing list
Blitz-bugs_at_[hidden]
http://www.oonumerics.org/mailman/listinfo.cgi/blitz-bugs