This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug c++/19263] [3.4/4.0 regression]: wrong-code: explicit inicialization of v8qi miscompiled


------- Additional Comments From jakub at gcc dot gnu dot org  2005-01-12 18:00 -------
This seems to be because of the CONSTRUCTOR_ELTS (init) = NULL;
added in http://gcc.gnu.org/ml/gcc-patches/2004-01/msg00832.html
by Richard.
If I remove it, the testcase works, as well as this bigger one below.
Wiping the initializers of the vector can't be right, so either that line
can be just deleted, or we want to create zero vector and then initialize
it field by field with the original values.
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
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 ();
  return 0;
}



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rth at gcc dot gnu dot org


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


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