This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53225] static operator new in multiple inheritance carries incorrect type information for the class
- From: "dimitrisdad at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 04 May 2012 19:25:08 +0000
- Subject: [Bug c++/53225] static operator new in multiple inheritance carries incorrect type information for the class
- Auto-submitted: auto-generated
- References: <bug-53225-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53225
--- Comment #9 from Thomas W. Lynch <dimitrisdad at gmail dot com> 2012-05-04 19:25:08 UTC ---
I went to take 'this_type' out of the source. You were correct to focus on
that.
As malloc() returns a void * there must be a cast to access the fields in the
instance. We routinely use 'this_type' in our shop, which is defined to be the
same as the class name. However, if you put the class name in, e.g. (A *)
malloc(..) then you would definitely get the offset for an A, even after the
method is inherited into a B.
The question comes down to, then, if when inheriting a method into a child, if
the typedefs in the child apply or the typedefs in the parent apply. It should
be the typedefs of the child, as offsets (type) is adjusted in inheritance. It
would eliminate a lot of otherwise valid looking code otherwise.
This looks to be a general issue with multiple inheritance having nothing to do
with operator new. Let me check that..
Though lets also keep in mind, the compiler makes no noise at all in this
situation.