This is the mail archive of the gcc@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]

Re: RTL alias analysis


"Dave Korn" <dave.korn@artimi.com> writes:

>   I think he's saying that _this_ one might generate invalid code:
> 
> void test(void)
> {
>         union { int i; double d; } u;
>         int *ip;
>         double *dp;
>         int ii;
>         double dd;
> 
>         dp = &u.d;
>         ip = &u.i;
>         *ip = 15;
>         ii = *ip;
>         *dp = 1.5;
>         dd = *dp;
>         printf("ii=%d dd=%f\n", ii, dd);
> }

That function is valid too.

Here is an example of an invalid function:

void test(void)
{
        union { int i; double d; } u;
        int *ip;
        double *dp;
        int ii;
        double dd;

        dp = &u.d;
        ip = &u.i;
        *ip = 15;
        *dp = 1.5;
        ii = *ip;
        dd = *dp;
        printf("ii=%d dd=%f\n", ii, dd);
}

Ian


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