User account creation filtered due to spam.

Bug 46863 - [4.6 Regression] Bogus memmove folding (?)
Summary: [4.6 Regression] Bogus memmove folding (?)
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: alias, wrong-code
Depends on:
Reported: 2010-12-09 11:51 UTC by Richard Biener
Modified: 2011-01-01 18:50 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2010-12-09 11:51:29 UTC
With -D_FORTIFY_SOURCE=2 memmove is folded to memcpy because of the restrict
qualified arguments of the memmove wrapper.

"Miscompiled" at -O1:

typedef __SIZE_TYPE__ size_t;
extern void *memmove (void *__dest, __const void *__src, size_t __n)
     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));

extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__artificial__)) void *
__attribute__ ((__nothrow__)) memmove (void *__restrict __dest, __const void *__restrict __src, size_t __len)

  return __builtin___memmove_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
extern void abort (void);
void __attribute__((noinline,noclone))
foo(void *p, void *q)
  memmove (p, q, 13);
int main()
  char a[32] = "Hello World!";
  foo (&a[1], a);
  if (strcmp (a, "HHello World!") != 0)
    abort ();
  foo (a, &a[1]);
  if (strcmp (a, "Hello World!") != 0)
    abort ();
  return 0;

But IMHO this is a serious glibc bug.
Comment 1 Andrew Pinski 2010-12-09 22:14:48 UTC
This really does look like a glibc bug rather than a GCC one.  The Restrict usage there I really think is an invalid use of it.
Comment 2 Richard Biener 2010-12-10 13:22:02 UTC