PATCH:mutable const objects
Wed Oct 28 02:31:00 GMT 1998
Here's a patch which fixes
http://www.cygnus.com/ml/egcs-bugs/1998-Jul/0346.html where a constant
object with a mutable member and a simple initializer would be placed in
.rodata rather than .data (ore equivalent sections on other
architectures). There was some discussion at
http://www.cygnus.com/ml/egcs/1998-Aug/0050.html about how to fix this.
I've added a new bitfield flag, has_mutable, to the lang_type struct.
this should be set on any structure which contains at least one mutable
member (recursively). I set this in finish_struct_1. Then in
cp_finish_decl, after any DECL_INITIAL is attached, if that is
TREE_CONSTANT, I check whether the type is a class with mutables. If so,
the TREE_CONSTANT is removed.
Two new macros are involved, CLASSTYPE_HAS_MUTABLE, which directly
access a class's has_mutable flag. And TYPE_HAS_MUTABLE which works for
any type (arrays are traversed and non class types return 0).
A test case is included which the current egcs places all the static
objects in rodata (and consequently segfaults at runtime).
I've stayed clear of the tortuous nature of SELECT_SECTION, this is just
a C++ patch.
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
You can up the bandwidth, but you can't up the speed of light
firstname.lastname@example.org http://www.cs.bris.ac.uk/~nathan/ email@example.com
More information about the Gcc-patches