This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH] reimplement -fstrict-volatile-bitfields v4, part 1/2

Hi Richard/Joseph,

I noticed, this test case crashes on arm-eabi already witout the patch.

extern void abort (void);

#define test_type unsigned short
#define MAGIC (unsigned short)0x102u

typedef struct s{
 unsigned char Prefix[1];
 test_type Type;
}__attribute((__packed__,__aligned__(4))) ss;

volatile ss v;
ss g;

void __attribute__((noinline))
foo (test_type u)
  v.Type = u;

test_type __attribute__((noinline))
bar (void)
  return v.Type;

However when compiled with -fno-strict-volatile-bitfields it does not crash,
but AFAIK the generated code for foo() violates the C++ memory model:

    @ Function supports interworking.
    @ args = 0, pretend = 0, frame = 0
    @ frame_needed = 0, uses_anonymous_args = 0
    @ link register save eliminated.
    ldr    r2, .L2
    ldr    r3, [r2]
    bic    r3, r3, #16711680
    bic    r3, r3, #65280
    orr    r3, r3, r0, asl #8
    str    r3, [r2]
    bx    lr

On Intel the generated code uses unaligned access, but is OK for the memory model:

    movw    %di, v+1(%rip)

Am I right, or is the code OK for the Memory model?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]