[Patch, fortran] PR33749 - Wrong evaluation of expressions in lhs of assignment statements
Paul Richard Thomas
paul.richard.thomas@gmail.com
Sun Oct 21 12:40:00 GMT 2007
:ADDPATCH fortran:
integer :: p(4) = (/2,4,1,3/)
p(p) = (/(i, i = 1, 4)/)
print *, p
end
Gives the wrong result with -m32 but the right one with -m64 because
the index expression is detected to be a function in the latter case,
thereby generating a temporary for it. Both modes work correctly if p
is declared integer(2). The fix is indicated by putting the index, p,
in perentheses. That is what this patch does - all lhs vector index
expressions are put in parentheses to force the creation of a
temporary. At the same time, I have cleaned up resolve_code a bit by
extracting the code associated with assignments into a new function.
The testcase fails in both modes, without the patch, by comparing two
identical expressions; one for integer(4) and the other for
integer(8).
Bootstraps and regtests on x86_ia64 - OK for trunk?
Paul
2007-10-21 Paul Thomas <pault@gcc.gnu.org>
PR fortran/33749
* resolve.c (resolve_ordinary_assign): New function that takes
the code to resolve an assignment from resolve_code. In
addition, it makes a temporary of any vector index, on the
lhs, using gfc_get_parentheses.
(resolve_code): On EXEC_ASSIGN call the new function.
2007-10-21 Paul Thomas <pault@gcc.gnu.org>
PR fortran/33749
* gfortran.dg/assign_9.f90: New test.
--
The knack of flying is learning how to throw yourself at the ground and miss.
--Hitchhikers Guide to the Galaxy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit.diff
Type: text/x-patch
Size: 7102 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20071021/fa4fb1b7/attachment.bin>
More information about the Gcc-patches
mailing list