On 11/22/13 12:44, Eric Botcazou wrote:
Hi,

this is a regression present on the mainline and 4.8 branch.  emit_group_store
happily writes past the end of a packed structure, thus accessing a distinct
variable stored there.  Then the scheduler swaps a couple of writes, leading
to wrong code.  Fixed by preventing emit_group_store from writing past the end
of the structure.

Tested on x86_64-suse-linux, OK for the mainline and 4.8 branch?

2013-11-22  Eric Botcazou  <ebotca...@adacore.com>

        PR middle-end/59138
        * expr.c (emit_group_store): Do not write past the end of the structure.
        (store_bit_field): Fix formatting.


2013-11-22  Eric Botcazou  <ebotca...@adacore.com>

        * gcc.c-torture/execute/20131122-1.c: New test.
It looks like this patch was for gcc-4.8; the code has changed a little since then.

I'm having a hard time seeing why this change was made:

       /* Optimize the access just a bit.  */
-      if (MEM_P (dest)
-         && (! SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (dest))
-             || MEM_ALIGN (dest) >= GET_MODE_ALIGNMENT (mode))
-         && bytepos * BITS_PER_UNIT % GET_MODE_ALIGNMENT (mode) == 0
-         && bytelen == GET_MODE_SIZE (mode))
+      else if (MEM_P (dest)
+              && (!SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (dest))
+                  || MEM_ALIGN (dest) >= GET_MODE_ALIGNMENT (mode))
+              && bytepos * BITS_PER_UNIT % GET_MODE_ALIGNMENT (mode) == 0
+              && bytelen == GET_MODE_SIZE (mode))
        emit_move_insn (adjust_address (dest, mode, bytepos), tmps[i]);

But that may be an artifact of looking at the trunk where the code is a bit different already.

Presumably you've verified this is still a problem on the trunk?

jeff

Reply via email to