This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Possible missing case for -Wcast-align
- From: Pedro Pedruzzi <pedro dot pedruzzi at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 30 Apr 2010 17:12:55 -0300
- Subject: Possible missing case for -Wcast-align
Hi,
gcc (for a STRICT_ALIGNMENT target and with -Wcast-align) do not warn
about the increasing of alignment requirement on the pointer assignments
present on the following C code.
struct {
short var;
} __attribute__((packed)) str;
void fun(void)
{
short *ptr;
ptr = (short *) (&str.var);
ptr = &str.var;
}
Is this the expected behavior in this case?
I don't think so. And I guess gcc is missing it by trusting the type's
(short) alignment requirement instead of the variable's (str.var
requires just byte-alignment).
Does anyone think this is an issue?
Regards,
--
Pedro Pedruzzi