------- Additional Comments From falk at debian dot org 2005-07-12 22:27 ------- (In reply to comment #0)
> Instead of generating the code to store a byte using unaligned load/store > instruction it uses aligned LDL/STL. The assembler code looks correct using > -O0 > optimization flag and incorrect with -O1 and -O2. I tried to write smaler test > case with the same pattern, but compiler compiles it correctly, so I am > attaching the original preprocessed source. The function to look at: > init_one_value. typedef char *gptr; typedef char my_bool; [...] static void init_one_value(const struct my_option *option, gptr *variable, longlong value) { switch ((option->var_type & 127)) { case 2: *((my_bool*) variable)= (my_bool) value; break; [...] At entry of the function, variable must be a null pointer, or point to an object of type gptr = char*. Because of the dereferencing, gcc can assume the former, and therefore *variable can be deduced to be 8-byte aligned. (BTW, the other cases violate aliasing rules, since they're not covered by the "lvalue of type char" exception.) -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22447