[email protected] (Ian Lance Taylor) wrote on 20.01.06 in <[EMAIL PROTECTED]>:
> 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