Structure assignment in Linux fails in ARM but succeeds in x86

后端 未结 4 1598
深忆病人
深忆病人 2020-12-06 21:25

I\'ve noticed something really strange. say I\'ve got the following structure defined

typedef struct
{
  uint32_t a;
  uint16_t b;
  uint32_t c;
} foo;
         


        
4条回答
  •  无人及你
    2020-12-06 21:49

    C Standard [ISO/IEC 9899:2011] - 6.3.2.3, paragraph 7:

    A pointer to an object or incomplete type may be converted to a pointer to a different object or incomplete type. If the resulting pointer is not correctly aligned for the pointed-to type, the behavior is undefined.

    Source: CERT Secure Coding Standards

提交回复
热议问题