[llvm-commits] [llvm-gcc-4.2] r43399 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Dale Johannesen dalej at apple.com
Wed Nov 7 08:14:57 PST 2007


On Nov 7, 2007, at 12:46 AM, Duncan Sands wrote:

> Hi Bill, the following testcase shows another problem:
>
> struct A
> {
>   int a[1024];
> };
> void g(struct A *a, struct A *b)
> {
>   *a = *b;
> }
> struct A c;
> int main(void)
> {
>   g(&c, &c);
> }
>
> Note that llvm-gcc generates a memcpy for the *a = *b
> assignment, but it should be memmove since *a and *b
> may be the same (as they are in this case).

While that's nonstandard, it's hard to imagine a memcpy  
implementation that would screw it up.
But they can partially overlap:

struct A { int a[1024]; }
struct B { int x; struct A y; };
union C { struct A x; struct B y; }
void g(struct A* a, struct A* b) { *a = *b; }
union C u;
main(void) { g(&u.x, &u.y.y);

I fixed this for structure return values a while back  (43324) but  
you're right that the problem is more general.




More information about the llvm-commits mailing list