[2.96 20000417] -O1 generates bad code
Ovidiu Toader
ovi@physics.utoronto.ca
Wed Apr 19 07:14:00 GMT 2000
This code illustrates the problem. The output should show twice "256 ==
256".
Correct output is obtained if:
** "E << n" is removed from the main
** E::operator<< is declared as "operator<<(int const)" instead of
"operator<<(int const &)".
Ovidiu
phoenix:Work/C++/bug1> uname -a
Linux phoenix.physics.utoronto.ca 2.2.14 #5 Mon Feb 7 18:45:19 EST 2000
alpha un
known
phoenix:Work/C++/bug1> g++ -v
Reading specs from
/usr/local/Packages/lang/egcs.new/install/lib/gcc-lib/alphaev
67-unknown-linux-gnu/2.96/specs
gcc version 2.96 20000417 (experimental)
phoenix:Work/C++/bug1> cat bug.cc
#include <iostream>
struct Error {
void operator<<(int const &) {
}
};
void
check_size(int const size) {
int n = size;
cerr << "256 == " << n << endl;
while( n%11 == 0 ){n /= 11;}
while( n%13 == 0 ){n /= 13;}
cerr << "256 == " << n << endl;
Error E;
E << n;
}
int
main(){
check_size(256);
}
phoenix:Work/C++/bug1> g++ -O1 -o exe bug.cc
phoenix:Work/C++/bug1> exe
256 == 256
256 == 1169680
More information about the Gcc-bugs
mailing list