Re: GCC 4.6.1 and strict-aliasing bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Torquil Macdonald Sørensen <torquil@xxxxxxxxx> writes:

> #include "iostream"
> #include "blitz/array.h"
>
> int main()
> {
> 	blitz::Array<double,1> X(3); X = 0.0;
>
> 	blitz::Array<double,1> var(1); var = 0.0;
>
> 	for(int i = 0; i != 1; ++i) {
> 		for(int c = 0; c != 3; ++c) X(c) = double(c);
>
> 		var(i) = 0.0;
> 		for(int c = 0; c != 3; ++c) var(i) += X(c)*X(c);
> 		var(i) /= 3.0;
> 	}
>
> 	std::cout << var(0) << std::endl;
>
> 	return(0);
> }
> ---------------------------
>
>
> If I compile with "-O2", it prints 0, which is wrong.
>
> If I compile with "-O2 -fno-strict-aliasing", it prints the correct answer 1.6666..

In every case I've looked at, when code gives the expected answer only
when using -fno-strict-aliasing, it is because the code is using a type
cast in an invalid way.

In this case I would assume that the invalid type cast occurs in the
blitz library code.  Look for invalid type casts there.

Ian



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux