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


ian@airs.com (Ian Lance Taylor)  wrote on 20.01.06 in <m3zmlqch5k.fsf@gossamer.airs.com>:

> When dealing with unions, you can take pointers to different fields in
> the unions.  If the fields have different types, these pointers can
> have non-conflicting alias sets.  Therefore within a single union the
> same memory can be read or written by different pointers.  This is
> considered to be invalid--a valid program is required to always access
> the memory within the union in the same type, except if you access the
> memory via the union type itself (this permission being a gcc
> extension).

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

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

So you're saying this function is not valid?

MfG Kai


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