[Patch, Fortran] PR fortran/31822: Runtime string length check for pointer assignment
Tobias Burnus
burnus@net-b.de
Thu Dec 18 10:08:00 GMT 2008
Daniel Kraft wrote:
> building upon my recent patch for PR 38137 (runtime string length
> checking for arguments to MERGE), this implements string length checks
> for pointer assignment enabled by -fbounds-check. Additionally, I
> changed the code doing the compile time checks to use
> gfc_check_same_strlen instead of doing it inline, which also means it
> gives a more detailed error message now (including the unequal string
> lengths).
>
> Regression testing on GNU/Linux-x86-32 at the moment, but I don't
> expect any (did a test on a nearly identical patch version before).
> Is this ok for trunk/4.4? Or should we wait for 4.5 with it, as it
> got a somewhat lengthier patch than the one before?
OK if it passed the regtesting.
+ /* Check character lengths if character expression. */
+ if (expr1->ts.type == BT_CHARACTER && expr2->expr_type != EXPR_NULL)
+ {
+ gcc_assert (expr2->ts.type == BT_CHARACTER);
+ gcc_assert (lse.string_length && rse.string_length);
+ gfc_trans_same_strlen_check ("pointer assignment", &expr1->where,
+ lse.string_length, rse.string_length,
+ &block);
+ }
I wonder whether one should add a comment that the check is only done
for -fbounds-check or not. (The option is checked for in
gfc_trans_same_strlen_check).
+! { dg-shouldfail "Unequal character lengths \\(17/10\\)" }
As written before in a private email, dg-shouldfail only looks at the
exit status code and does not do any pattern matching - the string is
only a comment. For pattern matching one has to use dg-output. Can you
fix this?
Tobias
More information about the Fortran
mailing list