This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch, fortran] internal compiler error related to matmul and transpose
- From: Tobias Burnus <burnus at net-b dot de>
- To: Jerry DeLisle <jvdelisle at verizon dot net>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 26 Nov 2009 22:43:27 +0100
- Subject: Re: [patch, fortran] internal compiler error related to matmul and transpose
- References: <4B0ED032.3090906@verizon.net>
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