This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR 84740 Wrong string length type in bounds check
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 10 Jan 2018 12:21:48 +0100
- Subject: Re: [PATCH] PR 84740 Wrong string length type in bounds check
- Authentication-results: sourceware.org; auth=none
- References: <1515583126-3205-1-git-send-email-blomqvist.janne@gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Jan 10, 2018 at 01:18:46PM +0200, Janne Blomqvist wrote:
Thanks for fixing this PR.
> @@ -1562,7 +1562,8 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc,
> if (first_len)
> {
> gfc_add_modify (&se->pre, first_len_val,
> - se->string_length);
> + fold_convert (TREE_TYPE (first_len_val),
> + se->string_length));
Wrong formatting, se->string_length should have been below TREE_TYPE.
> first_len = false;
> }
> else
> @@ -1571,7 +1572,9 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc,
> length. */
> tree cond = fold_build2_loc (input_location, NE_EXPR,
> logical_type_node, first_len_val,
> - se->string_length);
> + fold_convert (TREE_TYPE
> + (first_len_val),
> + se->string_length));
And here, it might have been better to add a temporary for
TREE_TYPE (first_len_val)
to avoid the excessive line wrapping.
Jakub