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]

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


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