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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-09-14
                 CC|                            |ebotcazou at gcc dot
                   |                            |gnu.org
     Ever Confirmed|0                           |1

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-09-14 
14:54:53 UTC ---
The big discrepancy between structures and unions comes from:

/* Compute the TYPE_MODE for the TYPE (which is a RECORD_TYPE).  */

void
compute_record_mode (tree type)
{
[...]

  /* If we only have one real field; use its mode if that mode's size
     matches the type's size.  This only applies to RECORD_TYPE.  This
     does not apply to unions.  */
  if (TREE_CODE (type) == RECORD_TYPE && mode != VOIDmode
      && host_integerp (TYPE_SIZE (type), 1)
      && GET_MODE_BITSIZE (mode) == TREE_INT_CST_LOW (TYPE_SIZE (type)))
    SET_TYPE_MODE (type, mode);
  else
    SET_TYPE_MODE (type, mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1));

so the structure is given XFmode but the union is given BKLmode.

Apparently someone has attempted to bridge the gap but this was reverted by:

------------------------------------------------------------------------
r37041 | wilson | 2000-10-25 03:30:25 +0200 (Wed, 25 Oct 2000) | 6 lines

Fixes for C++ structure layout breakage.
        * expmed.c (store_bit_field): Move integer pun code down after
        code that calls emit_move_insn for entire register move.
        * stor-layout.c (compute_record_mode): Revert Mar 25, Aug 18, and
        Oct 20 changes.  Only store mode in TYPE_MODE if RECORD_TYPE.

Reply via email to