------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-19 
19:00 -------
It can be confirmed on x86 with:
extern void abort (void);

#undef memcpy
#define memcpy(dst, src, len) \
  __builtin___memcpy_chk (dst, src, len, __builtin_object_size (dst, 0))

int
main (void)
{
  static const char data[] = { 0, 0x40, 0xe2, 0x01, 0x00, 0x01, 0x80, 0xc0, 
0x1d };
  const char *s = &data[1];
  int natint = data[0];
  unsigned long long tmp = 0;

  memcpy (&tmp, s, natint ? sizeof(tmp) : 4);
  if (sizeof(tmp) > 4 && (tmp>>32) != 0) /* movq generated? */
    abort ();

  return 0;
}

And here is a testcase for big endian:
extern void abort (void);

#undef memcpy
#define memcpy(dst, src, len) \
  __builtin___memcpy_chk (dst, src, len, __builtin_object_size (dst, 0))

int
main (void)
{
  static const char data[] = { 0, 0x40, 0xe2, 0x01, 0x00, 0x01, 0x80, 0xc0, 
0x1d };
  const char *s = &data[1];
  int natint = data[0];
  unsigned long long tmp = 0;

  memcpy (&tmp, s, natint ? sizeof(tmp) : 4);
  printf("%llx\n", tmp);
  if (sizeof(tmp) > 4 && (tmp &0xFFFFFF) != 0) /* 64bit move generated? */
    abort ();

  return 0;
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
 GCC target triplet|x86_64-*-linux-gnu          |
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-19 19:00:31
               date|                            |


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

Reply via email to