------- Additional Comments From tsv at solvo dot ru  2005-07-12 22:48 -------
(In reply to comment #3)
> (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.)

Ok. Thank you very much for explanation. Unfortunatelly, with switching to gcc
4.x some code started to produce such exceptions (with gcc 3.4 everything was
fine). Is there an option to make gcc think that passed *variable is char * and
can't be null pointer? Why the simpe test case (that contains the same function
and a function that calls it) produces the correct code (I could attach it if
you have time to take a look at it). Thans again.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22447

Reply via email to