René Scharfe <l....@web.de> writes:

>       @ depends on r @
>       expression E;
>       @@
>       - *&
>         E

I guess my source of the confusion is that the tool that understands
the semantics of the C language still needs to be told about that.

I was hoping that something that understands C only needs to be told
only a single rule:

        type T
        T src, dst

        -memcpy(&dst, &src, sizeof(dst));
        +dst = src;

and then can apply that rule to this code in four ways:

        struct foo A, *Bp;

        memcpy(Bp, &A, sizeof(*Bp));
        memcpy(Bp, &A, sizeof(A));
        memcpy(&src, dstp, sizeof(A));
        memcpy(&src, dstp, sizeof(*Bp));

to obtain its rewrite:

        struct foo A, *Bp;

        *Bp = A;
        *Bp = A;
        A = *Bp;
        A = *Bp;

by knowing that (*Bp) is of type "struct foo" (even though Bp is of
type "struct foo *") and sizeof(dst) and sizeof(src) are the same
thing in the rule because src and dst are both of type T.

Reply via email to