This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Base class layout in C++
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 18 Dec 2003 11:15:11 +0100
- Subject: Base class layout in C++
Hi,
The following testcase ICEs on mainline on SPARC64:
class v
{
double x, y;
public:
v();
};
class w : public v {
public:
w();
};
void bar(w x);
void foo()
{
w my_w;
bar(my_w);
}
Given that the size of struct 'w' is equal to 16 bytes, 'my_w' will be passed
by value to 'bar'. The SPARC back-end then needs to know the DECL_SIZE and
DECL_MODE of the fields 'x' and 'y', as seen through the derived struct, in
order to generate the call to 'bar'. Now DECL_SIZE is 0 and DECL_MODE is
VOIDmode for both fields, which confuses the back-end.
Questions:
(1) Should the C++ front-end have laid out the base struct?
(2) If no, should the middle-end (calls.c for example) lay it out?
(3) If no, should the back-end resort to TYPE_SIZE and TYPE_MODE?
I think (3) may be negatively answered by these lines from tree.h:
/* Holds the machine mode corresponding to the declaration of a variable or
field. Always equal to TYPE_MODE (TREE_TYPE (decl)) except for a
FIELD_DECL. */
#define DECL_MODE(NODE) (DECL_CHECK (NODE)->decl.mode)
--
Eric Botcazou