public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/19263] [3.4/4.0 regression]: wrong-code: explicit inicialization of v8qi miscompiled
Date: Wed, 12 Jan 2005 18:30:00 -0000	[thread overview]
Message-ID: <20050112183042.22901.qmail@sourceware.org> (raw)
In-Reply-To: <20050105125215.19263.smelkov@mph1.phys.spbu.ru>


------- Additional Comments From jakub at gcc dot gnu dot org  2005-01-12 18:30 -------
Tested to also test static initializers:
typedef signed char v8qi __attribute__ ((vector_size (8)));

extern "C" void abort (void);

static unsigned char S[16];

struct A
{
  int i;
  v8qi j, k;
  int l;
};

void
foo (unsigned char v)
{
  A a = { 1, { v, v, v, v, v, v, v, v },
          { v + 1, v + 1, v + 1, v + 1, v + 1, v + 1, v + 1, v + 1 }, 3 };
  v8qi *s = (v8qi *) &S[0];
  *s = a.j;
  s[1] = a.k;
}

void
bar (unsigned char v)
{
  v8qi val8 = { v, v, v, v, v, v, v, v };
  v8qi *s = (v8qi *) &S[0];
  *s = val8;
}

int n = 5, cnt;

int
num (void)
{
  ++cnt;
  return n;
}

void
baz (void)
{
  static A a = { 0, { num (), num (), num (), num (), 6, 6, 6, 6 },
                 { 7, 7, 7, 7, 8, 8, 8, 8 }, 0 };
  v8qi *s = (v8qi *) &S[0];
  *s = a.j;
  s[1] = a.k;
}

int
main ()
{
  int i;
  foo (1);
  for (i = 0; i < 8; ++i)
    if (S[i] != 1)
      abort ();
  for (; i < 16; ++i)
    if (S[i] != 2)
      abort ();
  bar (3);
  for (i = 0; i < 8; ++i)
    if (S[i] != 3)
      abort ();
  baz ();
  if (cnt != 4)
    abort ();
  for (i = 0; i < 16; ++i)
    if (S[i] != 5 + (i / 4))
      abort ();
  return 0;
}

Works with G++ 3.2.x, fails with 3.4.x and mainline, even with:
--- typeck2.c.jj        2005-01-12 18:34:32.000000000 +0100
+++ typeck2.c   2005-01-12 19:19:28.602047217 +0100
@@ -348,8 +348,9 @@ split_nonconstant_init_1 (tree dest, tre
     case VECTOR_TYPE:
       if (!initializer_constant_valid_p (init, type))
        {
+         tree cons = copy_node (init);
          CONSTRUCTOR_ELTS (init) = NULL;
-         code = build (MODIFY_EXPR, type, dest, init);
+         code = build (MODIFY_EXPR, type, dest, cons);
          code = build_stmt (EXPR_STMT, code);
          pcode = &TREE_CHAIN (code);
        }

patch.

-- 


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


  parent reply	other threads:[~2005-01-12 18:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-05 12:52 [Bug c++/19263] New: [g++-3.4.3 " smelkov at mph1 dot phys dot spbu dot ru
2005-01-05 14:48 ` [Bug c++/19263] [3.4/4.0 " pinskia at gcc dot gnu dot org
2005-01-05 14:57 ` pinskia at gcc dot gnu dot org
2005-01-12 17:30 ` jakub at gcc dot gnu dot org
2005-01-12 18:00 ` jakub at gcc dot gnu dot org
2005-01-12 18:30 ` jakub at gcc dot gnu dot org [this message]
2005-01-12 19:16 ` pinskia at gcc dot gnu dot org
2005-01-14 23:46 ` [Bug c++/19263] [3.4/4.0 regression]: wrong-code: explicit initialization " cvs-commit at gcc dot gnu dot org
2005-01-14 23:52 ` cvs-commit at gcc dot gnu dot org
2005-01-15  1:50 ` pinskia at gcc dot gnu dot 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=20050112183042.22901.qmail@sourceware.org \
    --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).