[patch, fortran] internal compiler error related to matmul and transpose
Tobias Burnus
burnus@net-b.de
Thu Nov 26 21:45:00 GMT 2009
Jerry DeLisle wrote:
> Hi, this patch is trivial.
I beg to differ - it is the opposite: It is rather nonintuitive.
However, I think it is correct.
src_ss = gfc_walk_expr (expr);
> src_info = &src_ss->data.info;
> dest_info = &dest_ss->data.info;
> gcc_assert (dest_info->dimen == 2);
> - gcc_assert (src_info->dimen == 2);
The problem with using src_ss->data.info.dimen is the following: src_ss
is a linked list; in gfc_walk_op_expr the order for "scalar <operator>
array" is reverted. In gfc_walk_expr(), the order is then reverted back
via gfc_reverse_ss.
Thus: for "0.5*matA" the first element of the linked list as returned by
gc_walk_expr is for the scalar "0.5" which has "dimen == 0". For
"matA*0.5" one gets the one for "matA" which has the expected "2".
An alternative would be to check:
/* dimen has to be 2 or - for expressions starting with a scalar
operator - 0. */
gcc_assert (src_info->dimen == 2 || src_info->dimen == 0);
(Or, if one wants to be pedantic, one could walk the list and check that
all are either 0 or 2 - and check further that at least one is 2, but I
think that is too much checking for little gain.)
For the result (dest_info) the dimen check is OK as it cannot be an
expression involving scalars but has to be assignable.
Tobias
More information about the Gcc-patches
mailing list