public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bernd.edlinger at hotmail dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/57748] [4.7/4.8/4.9 Regression] ICE when expanding assignment to unaligned zero-sized array
Date: Mon, 09 Sep 2013 06:41:00 -0000	[thread overview]
Message-ID: <bug-57748-4-bJJnG0m934@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-57748-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #34 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Hmm, this was looking like a working example ((if it is valid C at all)),
but after some thougt, I saw now it exposes a data store race:

#include <stdio.h>
#include <string.h>

typedef long long V
  __attribute__ ((vector_size (2 * sizeof (long long)), may_alias));
union x
{
   long long a;
   float b;
} __attribute__((aligned(1))) ;

struct s
{
  union x xx[0];
  V x;

} __attribute__((packed));

void __attribute__((noinline, noclone))
foo(struct s * x)
{
  x->xx[0].a = -1;
  x->xx[0].b = 3.14;
  x->x[1] = 0x123456789ABCDEF;
}

int
main()
{
  struct s ss;
  memset(&ss, 0, sizeof(ss));
  foo (&ss);
  printf("%f %llX\n", ss.xx[0].b, ss.xx[0].a);
  printf("%llX %llX\n", ss.x[0], ss.x[1]);
}

the resulting code is:

foo:
.LFB23:
        .cfi_startproc
        movdqu  (%rdi), %xmm0
        movabsq $-4294967296, %rdx
        movq    .LC1(%rip), %xmm1
        psrldq  $8, %xmm0
        punpcklqdq      %xmm0, %xmm1
        movdqu  %xmm1, (%rdi)
        movdqu  (%rdi), %xmm2
        movdqa  %xmm2, -24(%rsp)
        movq    -24(%rsp), %rax
        andq    %rdx, %rax
        orq     $1078523331, %rax
        movq    %rax, -24(%rsp)
        movdqa  -24(%rsp), %xmm3
        movdqu  %xmm3, (%rdi)
        movdqu  (%rdi), %xmm0
        movhps  .LC2(%rip), %xmm0
        movdqu  %xmm0, (%rdi)
        ret

Which shows all read/write accesses are 16 byte at a time and this creates
a forbidden data store race.
Looks like I shot my own patch down now :-)


  parent reply	other threads:[~2013-09-09  6:41 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-28  3:57 [Bug target/57748] New: ICE on ARM with -mfloat-abi=softfp -mfpu=neo raj.khem at gmail dot com
2013-06-28  3:58 ` [Bug target/57748] " raj.khem at gmail dot com
2013-06-28  4:00 ` raj.khem at gmail dot com
2013-06-28 14:52 ` jamborm at gcc dot gnu.org
2013-07-03 16:34 ` philb at gnu dot org
2013-07-05 13:24 ` [Bug tree-optimization/57748] " ramana at gcc dot gnu.org
2013-07-05 15:54 ` [Bug middle-end/57748] [4.8/4.9 Regression] ICE on ARM with -mfloat-abi=softfp -mfpu=neon pinskia at gcc dot gnu.org
2013-07-26 16:47 ` jamborm at gcc dot gnu.org
2013-07-29 20:49 ` bernd.edlinger at hotmail dot de
2013-07-30 14:53 ` jamborm at gcc dot gnu.org
2013-07-30 22:53 ` bernd.edlinger at hotmail dot de
2013-07-31 14:08 ` jamborm at gcc dot gnu.org
2013-07-31 16:39 ` jamborm at gcc dot gnu.org
2013-07-31 16:42 ` jamborm at gcc dot gnu.org
2013-08-01  2:10 ` bernd.edlinger at hotmail dot de
2013-08-01 14:40 ` [Bug middle-end/57748] [4.8/4.9 Regression] ICE when expanding assignment to unaligned zero-sized array jamborm at gcc dot gnu.org
2013-08-02  7:11 ` bernd.edlinger at hotmail dot de
2013-08-02 12:31 ` jamborm at gcc dot gnu.org
2013-08-02 22:49 ` bernd.edlinger at hotmail dot de
2013-08-03 22:36 ` david.abdurachmanov at gmail dot com
2013-08-06 20:30 ` david.abdurachmanov at gmail dot com
2013-08-28  8:20 ` rguenth at gcc dot gnu.org
2013-08-28  9:00 ` bernd.edlinger at hotmail dot de
2013-08-29 21:29 ` bernd.edlinger at hotmail dot de
2013-08-30 18:21 ` jamborm at gcc dot gnu.org
2013-08-31 18:13 ` bernd.edlinger at hotmail dot de
2013-09-02 23:35 ` bernd.edlinger at hotmail dot de
2013-09-03 10:12 ` rguenth at gcc dot gnu.org
2013-09-04  9:18 ` bernd.edlinger at hotmail dot de
2013-09-04  9:33 ` bernd.edlinger at hotmail dot de
2013-09-04  9:59 ` rguenth at gcc dot gnu.org
2013-09-04 10:04 ` [Bug middle-end/57748] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
2013-09-04 10:17 ` bernd.edlinger at hotmail dot de
2013-09-06  7:05 ` bernd.edlinger at hotmail dot de
2013-09-06  8:12 ` rguenth at gcc dot gnu.org
2013-09-09  6:41 ` bernd.edlinger at hotmail dot de [this message]
2013-09-09 13:02 ` bernd.edlinger at hotmail dot de
2013-09-10  7:56 ` bernd.edlinger at hotmail dot de
2013-09-18 14:44 ` jamborm at gcc dot gnu.org
2013-09-18 16:32 ` bernd.edlinger at hotmail dot de
2013-09-19  9:03 ` bernd.edlinger at hotmail dot de
2013-09-20  7:38 ` rguenther at suse dot de
2013-09-20 13:50 ` bernd.edlinger at hotmail dot de
2013-09-20 14:10 ` edlinger at gcc dot gnu.org
2013-10-16  9:49 ` jakub at gcc dot gnu.org
2013-10-30 13:07 ` rguenth at gcc dot gnu.org
2013-11-14 15:19 ` bernd.edlinger at hotmail dot de
2013-11-21 14:27 ` paulo@matos-sorge.com
2013-11-21 14:38 ` bernd.edlinger at hotmail dot de
2013-11-21 14:40 ` paulo@matos-sorge.com
2013-11-22 11:38 ` paulo@matos-sorge.com
2013-11-28  9:50 ` paulo@matos-sorge.com
2014-01-08 17:25 ` edlinger at gcc dot gnu.org
2014-02-05 17:54 ` mpolacek at gcc dot gnu.org
2014-05-22  9:05 ` [Bug middle-end/57748] [4.7/4.8 " rguenth at gcc dot gnu.org
2014-12-19 13:36 ` [Bug middle-end/57748] [4.8 " jakub at gcc dot gnu.org
2015-01-16 15:48 ` ramana at gcc dot gnu.org
2015-01-16 16:08 ` bernd.edlinger at hotmail dot de
2015-01-16 16:36 ` ramana at gcc dot gnu.org
2015-01-16 19:45 ` mikpelinux at gmail dot com
2015-01-22  8:28 ` mikpelinux at gmail dot com
2015-01-25 14:28 ` mikpelinux at gmail dot com
2015-01-26 23:40 ` bernd.edlinger at hotmail dot de
2015-01-27  8:47 ` mikpelinux at gmail dot com
2015-01-27 17:08 ` edlinger at gcc dot gnu.org
2015-01-27 17:10 ` edlinger at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-57748-4-bJJnG0m934@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).