g++ bug report for SUN architecture
Bastien Chevreux
bach@mwgdna.com
Fri Sep 29 15:14:00 GMT 2000
/*
g++ bug report (Bastien Chevreux -- bach@mwgdna.com)
Type: probably optimizer bug
Systems where bug appeared appeared first: SUN Solaris 2.7
GCC version: gcc 2.95.2
>>> Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs : gcc version 2.95.2 19991024 (release)
Bug was reproducible on: SUN Solaris 2.51
GCC version: egcs 1.1.1
>>> Reading specs from /home/chevreux/pub/SunOS/local/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.91.60/specs : gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
Bug did not appear on crosschecked machine: Linux 2.2 for x86
GCC version: 2.95.2
>>> Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.2/specs : gcc version 2.95.2 19991024 (release)
How to reproduce the bug (on the concerned systems):
Save this file as: cerror.C
Compile this code with: g++ -O cerror.C
Start with: ./a.out
The (wrong) output is:
############ 0
############ 2
############ 4
The correct behaviour can be seen by compiling without -O: g++ cerror.C
Start with: ./a.out
The (correct) output is:
############ 0
############ 1
############ 2
############ 3
############ 4
When uncommenting the cout in line 67, the bug disappears even when compiled
with -O
*/
#include <iostream.h>
class terror{
};
void testthrow()
{
terror t;
throw(t);
}
int main(void)
{
for(int i=0; i < 5; i++ ) {
cout << "############ " << i << endl;
try{
testthrow();
}
catch(terror t){
}
// when the folowing cout is uncommented, the bug does not appear
// even when compiled with -O
// cout << "y";
}
return 0;
}
More information about the Gcc-bugs
mailing list