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 tree-optimization/42821] [4.5 Regression] TCL is miscompiled



------- Comment #3 from rguenth at gcc dot gnu dot org  2010-01-21 11:34 -------
Or even

struct X {
    struct Y {
        char s[4];
    } y;
};

void * __attribute__((noinline,noclone))
myalloc (unsigned int sz)
{
  return __builtin_malloc (sz);
}

int main()
{
  struct X *p = myalloc (sizeof (struct Y)
                         + sizeof ("Hello World") + 1 - 4);
  struct Y *q = &p->y;
  __builtin___strcpy_chk (q->s, "Hello World",
                          __builtin_object_size (q->s, 1));
  return 0;
}

(warns)

vs.

struct X {
    struct Y {
        char s[4];
    } y;
};

void * __attribute__((noinline,noclone))
myalloc (unsigned int sz)
{
  return __builtin_malloc (sz);
}

int main()
{
  struct X *p = myalloc (sizeof (struct Y)
                         + sizeof ("Hello World") + 1 - 4);
  struct Y *q = (struct Y *)p;
  __builtin___strcpy_chk (q->s, "Hello World",
                          __builtin_object_size (q->s, 1));
  return 0;
}

(does not warn)


-- 


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


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