[Bug tree-optimization/88739] [7/8/9 Regression] Big-endian union bug

rsandifo at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 9 17:33:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88739

rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rsandifo at gcc dot gnu.org

--- Comment #35 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Yeah, the expr.c patch makes the original testcase work, but we still fail for:

#include<stdio.h>
typedef  unsigned int U32;
typedef  unsigned short  U16;
typedef  unsigned char U8;

typedef struct MEM_HEAD_4DW
{
    /* first word */
    U32 b11               : 1;
    U32 b12               : 3;
    U32 b13               : 3;
    U32 b14               : 1;
    U32 b15               : 16;
    U32 b16               : 8;

    /* second word */
    U32 b21               : 16;
    U32 b22               : 1;
    U32 b23               : 4;
    U32 b24               : 11;

    /* third word */
    U32 b31               : 32;

    /* fourth word */
    U32 b30AddrL          : 30;
    U32 b2AddrType        : 2;
}MEM_REQ_HEAD_4DW;

typedef union HEAD_DW4_UNION
{
    MEM_REQ_HEAD_4DW strMemHead;
    U32 aulValue[4];
    U16 ausValue[8];
            U8  aucValue[16];
}HEAD_REQ_DW4_UNION;



U32 Test_func(U32 ulAddr)
{
    HEAD_REQ_DW4_UNION unData;

    unData.strMemHead.b30AddrL        = ulAddr >> 2;
    unData.strMemHead.b2AddrType      = 0;
    printf("unData.ausValue[6]=0x%x\r\n",unData.ausValue[6]);       // why get
0x0 instead of 0x1 ?

    return 0;
}

int main()

{
  Test_func(0x10224);
  return 0;
}

Like Wilco says, the torture test seems to pass with an unpatched compiler (but
seems like a good thing to have anyway).


More information about the Gcc-bugs mailing list