N
Noob
Hello,
My compiler complains when I take the address of a member in a union.
$ cat mu.c
union foo
{
int i;
double d;
};
int main(void)
{
union foo bar = { 0 };
int *p = &(bar.i);
return *p;
}
$ cc mu.c
w "mu.c",L10/C12(#241): Address of a union member is being used as a
| pointer. This may violate an assumption made by the optimizer.
| To be safe, you should recompile your program at a lower
| optimization level; or else, turn off the BEHAVED toggle.
No errors 1 warning
I don't see what the problem is, and gcc did not seem to mind.
$ gcc -O2 -std=c89 -Wall -Wextra mu.c
/* NO OUTPUT */
Is this an aliasing problem?
What am I doing wrong?
Regards.
My compiler complains when I take the address of a member in a union.
$ cat mu.c
union foo
{
int i;
double d;
};
int main(void)
{
union foo bar = { 0 };
int *p = &(bar.i);
return *p;
}
$ cc mu.c
w "mu.c",L10/C12(#241): Address of a union member is being used as a
| pointer. This may violate an assumption made by the optimizer.
| To be safe, you should recompile your program at a lower
| optimization level; or else, turn off the BEHAVED toggle.
No errors 1 warning
I don't see what the problem is, and gcc did not seem to mind.
$ gcc -O2 -std=c89 -Wall -Wextra mu.c
/* NO OUTPUT */
Is this an aliasing problem?
What am I doing wrong?
Regards.