SEGV in do_simple_structure_copy

Daniel Berlin dberlin@dberlin.org
Thu Oct 6 20:23:00 GMT 2005


On Oct 6, 2005, at 12:00 PM, Olivier Hainque wrote:

> Hello,
>
> The Ada testcase below, compiled with -O2 on x86-linux, triggers a
> SEGV in the current mainline compiler, there:
>
>    do_simple_structure_copy
>    { ...
>      for (; p && p->offset < last; p = p->next)
>        { ...
>          q = first_vi_for_offset (q, q->offset + fieldoffset);
>   ==>    temprhs.var = q->id;
>
> Below is a description of what is going on, plus suggestions on how to
> address the problem. I'd welcome feedback before submitting a patch
> with all the required testing process.
>
> The test basically constructs a record type with two 6bits long
> components, each of a record type also, and the two components (called
> key1 and key2) are tighly packed with a representation clause (no
> hole between the two components). Something like:
>
>       6bits   6bits
>     |.......|.......|
>       key1    key2
>
> Eventhough the field *decls* specify a 6bits length, the *type* of
> each is actually QI integer (8bits long).

IOW, you are lying to the middle-end about the size of the fields.
Why is the type not a 6 bit integer?


>
> A very simple way to deal with this is to just 'break' out of the loop
> when 'q' happens to be null, with an appropriate comment briefly
> explaining how this could happen.
>
Except that it should never happen.
We should never have a case where we've computed the sizes wrong,  
such that a simple structure copy fails.
Simply breaking out of this loop will cause you erorrs later.

> Another way would be to compute the incoming 'size' argument from decl
> information when appropriate. This seems more involved at first sight.

This is the correct fix, however, if you are going to lie to the  
middle end about TYPE_SIZE so that the TYPE_SIZE and DECL_SIZE do not  
match.






More information about the Gcc mailing list