C++ bug report for Egcs

Kyle A. Mestery mesteka@anubis.network.com
Wed Jun 30 05:23:00 GMT 1999


Greetings,

I think I may have stumbled upon a compiler bug.  First, some information
on the system on which this occurs:

Linux/ARM with kernel v2.2.10-rmk2-stk2, with compiler version (gcc version
egcs-2.91.66 19990325/philb (egcs-1.1.2 release)).  Here is the compile
line that recreates the problem:

gcc -mcpu=strongarm110 -mapcs-32 -O2 -fno-builtin -fno-exceptions -fvolatile -Wall -g nr.cc

Here is a description of the problem.  I have attached both the c++ file
and the preprocessed output:

The program that causes the bug is attached.  The attached c++ program
basically defines two classes, A and B.  A contains an array of class B
in it.  The destructor and constructor for A do nothing, and the
destructor and constructor for B simply print out the 'this' pointer.
The main loop of the program simply news an instance of A, and then
deletes that instance.

What I'm seeing is that the this pointers in the constructors do not match
the this pointers in the destructors.  I have tried this on three
platforms:

1) Linux/ARM running 2.2.10-rmk2-stk2, with compiler version (gcc version
egcs-2.91.66 199903 25/philb (egcs-1.1.2 release)).
2) vxWorks 5.4, with compiler versions gcc version 2.8.1 and Egcs
version (gcc driver version 2.7.9-970819 egcs-971225 tornado 2.0
executing gcc version 2.7.9-970819).
3) Solaris 2.5.1 with compiler version gcc version 2.7.2.2.

The code fails on both of the ARM platforms, and works correctly under
Solaris (i.e. the 'this' pointers all match up.)  It looks like it might
be a ARM specific problem.  Does anyone have any ideas about this?

Also, it's worth noting that on the ARM platforms, removing -fvolatile
as a compile line does not cause this to happenn, i.e. the this pointers
look valid.

Also, I sent this to the Linux/ARM list first, and here is what Philip
Blundell said about the problem:

> It appears that with -fvolatile the destructor code for class MyTest is 
> copying the object into its stack frame (and then calling the OtherClass 
> destructor on the copy).  This also happens with the current gcc 2.95 
> sources on ARM, and with egcs 1.1.1 on Intel.
> 
> I only have the most rudimentary understanding of C++ so I can't say whether 
> this is acceptable behaviour or not.  If it really is a bug I can dig a
> little 
> deeper into what is going on.

Any information on this would be most appreciated.  Thank you.

--
Kyle Mestery				   | http://www.freebsd.org/
StorageTek's Storage Networking Group	   | http://www.netwinder.org/
7600 Boone Ave. N., Minneapolis, MN 55428  | http://www.network.com/



More information about the Gcc-bugs mailing list