[Bug c++/37798] unaligned memory access with multiple inheritance

ebotcazou at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Oct 15 10:20:00 GMT 2009



------- Comment #3 from ebotcazou at gcc dot gnu dot org  2009-10-15 10:20 -------
The problem comes from cp/layout_class_type: it creates the version of the
class to be used for virtual bases before laying out the virtual base classes
of the class itself, in particular its alignment is set to the current
alignment:

      TYPE_ALIGN (base_t) = rli->record_align;

which may not be the final alignment if virtual base classes are more aligned,
i.e. if 

  layout_virtual_bases (rli, empty_base_offsets);

bumps rli->record_align.  As a result, TYPE_ALIGN > CLASSTYPE_ALIGN for the
class type so virtual bases that have this class type aren't aligned enough
when they are passed as 'this' to the methods of the class.

Jason, any ideas to solve this?


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot
                   |                            |org, ebotcazou at gcc dot
                   |                            |gnu dot org
         AssignedTo|ebotcazou at gcc dot gnu dot|unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW
          Component|target                      |c++
      Known to fail|3.4.3 4.2.4 4.3.4 4.4.0     |3.4.3 4.2.4 4.3.4 4.4.0
                   |                            |4.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37798



More information about the Gcc-bugs mailing list