This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
GNU C++ bug report
- To: gcc-bugs at gcc dot gnu dot org
- Subject: GNU C++ bug report
- From: "Peter A. Buhr" <pabuhr at plg2 dot math dot uwaterloo dot ca>
- Date: Mon, 18 Dec 2000 16:53:09 -0500 (EST)
The program below displays inconsistent behaviour. It produces different output
if the fields of class "owl" are interchanged. The problem occurs on this
environment:
@tcl[140]% uname -a
Linux tcl 2.2.16-22 #1 Tue Aug 22 16:49:06 EDT 2000 i686 unknown
@tcl[141]% gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.0)
The problem does *NOT* occur with:
@plg2[1]% gcc -v
Reading specs from /.software/arch/gcc-2.95.2/distribution/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs
gcc version 2.95.2 19991024 (release)
on any OS I have access to. Nor has the problem occurred in previous versions
of gcc. I have a work-around, but it's ugly so fixing this is important for me.
Thanks in advance.
=======================================================
#include <ostream.h>
class foo {
public:
foo();
};
foo f; // prints 1st line of output
class bar {
}; // bar
class module {
public:
static bar *b;
static double storage[10];
};
foo::foo() {
cout << module::b << endl;
};
class owl {
public:
int i; // interchange these two fields and get different results
bar p;
}; // owl
double module::storage[10] = {0.0};
// should be a compile-time calculation
bar *module::b = &(((owl *)&module::storage)->p);
foo g; // prints 2nd line of output
int main() {
}