This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] PR30190 - Bounds check generates wrong code for associated(p1(i)%p2,p1(i)%p2)


:ADDPATCH fortran:

This is a salutory lesson as to when and how to fix an expression
using gfc_evaluate_now.  The offending line in trans-array.c
(gfc_conv_array_ref) assigned the gfc_evaluate_now to the tree
variable that was its first argument, without adding the resulting
expression to a block.  The result was that the declarations were
added to se->pre but all the assignments were lost except the last.
Unfortunately, the all the index variables that were declared were
subsequently used and a segfault occurred.

The proposed fix is highly economical; just remove the line that fixes
the expression!  This inserts the expression for the index in the
array reference, rather than a temporary, into the tree expression for
the overall index.  In the case where the fortran index is 'i', the
resulting code is marginally more readable.  The testcase is that of
the reporter, except that the PRINT statement is replaced by an
assignment to a logical variable.

Regtested on Cygwin_NT/PIV - OK for trunk and 4.2?

Paul

Attachment: Change.Logs
Description: Text document

Attachment: pr30190.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]