* [Patch, fortran] PR52162 - Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
@ 2018-01-08 14:36 Paul Richard Thomas
2018-01-11 17:20 ` Paul Richard Thomas
0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2018-01-08 14:36 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 555 bytes --]
I post this patch early last year and did not submit because I was up
to my eyeballs with PR34640. I just forgot about it until it came up
on clf a few days ago.
Bootstraps and regtests on FC23/x86_64 - OK for trunk?
Paul
2018-01-08 Paul Thomas <pault@gcc.gnu.org>
PR fortran/52162
* trans-expr.c (gfc_trans_scalar_assign): Flag is_alloc_lhs if
the rhs expression is neither an elemental nor a conversion
function.
2018-01-08 Paul Thomas <pault@gcc.gnu.org>
PR fortran/52162
* gfortran.dg/bounds_check_19.f90 : New test.
[-- Attachment #2: submit.diff --]
[-- Type: text/plain, Size: 2031 bytes --]
Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c (revision 256335)
--- gcc/fortran/trans-expr.c (working copy)
*************** gfc_trans_assignment_1 (gfc_expr * expr1
*** 9924,9932 ****
/* Walk the lhs. */
lss = gfc_walk_expr (expr1);
if (gfc_is_reallocatable_lhs (expr1)
! && !(expr2->expr_type == EXPR_FUNCTION
! && expr2->value.function.isym != NULL))
lss->is_alloc_lhs = 1;
rss = NULL;
if ((expr1->ts.type == BT_DERIVED)
--- 9924,9935 ----
/* Walk the lhs. */
lss = gfc_walk_expr (expr1);
if (gfc_is_reallocatable_lhs (expr1)
! && !(expr2->expr_type == EXPR_FUNCTION
! && expr2->value.function.isym != NULL
! && !(expr2->value.function.isym->elemental
! || expr2->value.function.isym->conversion)))
lss->is_alloc_lhs = 1;
+
rss = NULL;
if ((expr1->ts.type == BT_DERIVED)
Index: gcc/testsuite/gfortran.dg/bounds_check_19.f90
===================================================================
*** gcc/testsuite/gfortran.dg/bounds_check_19.f90 (nonexistent)
--- gcc/testsuite/gfortran.dg/bounds_check_19.f90 (working copy)
***************
*** 0 ****
--- 1,24 ----
+ ! { dg-do run }
+ ! { dg-options "-fbounds-check" }
+ !
+ ! Test the fix for PR52162 in which the elemental and conversion
+ ! intrinsics in lines 14 and 19 would cause the bounds check to fail.
+ !
+ ! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
+ !
+ integer(4), allocatable :: a(:)
+ integer(8), allocatable :: b(:)
+ real, allocatable :: c(:)
+ allocate (b(7:11), source = [7_8,8_8,9_8,10_8,11_8])
+
+ a = b ! Implicit conversion
+
+ if (lbound (a, 1) .ne. lbound(b, 1)) call abort
+ if (ubound (a, 1) .ne. ubound(b, 1)) call abort
+
+ c = sin(real(b(9:11))/100_8) ! Elemental intrinsic
+
+ if ((ubound(c, 1) - lbound(c, 1)) .ne. 2) call abort
+ if (any (nint(asin(c)*100.0) .ne. b(9:11))) call abort
+ deallocate (a, b, c)
+ end
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, fortran] PR52162 - Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
2018-01-08 14:36 [Patch, fortran] PR52162 - Bogus -fcheck=bounds with realloc on assignment to unallocated LHS Paul Richard Thomas
@ 2018-01-11 17:20 ` Paul Richard Thomas
2018-01-11 17:26 ` Steve Kargl
0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2018-01-11 17:20 UTC (permalink / raw)
To: fortran, gcc-patches
Ping!
On 8 January 2018 at 14:36, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> I post this patch early last year and did not submit because I was up
> to my eyeballs with PR34640. I just forgot about it until it came up
> on clf a few days ago.
>
> Bootstraps and regtests on FC23/x86_64 - OK for trunk?
>
> Paul
>
> 2018-01-08 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/52162
> * trans-expr.c (gfc_trans_scalar_assign): Flag is_alloc_lhs if
> the rhs expression is neither an elemental nor a conversion
> function.
>
> 2018-01-08 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/52162
> * gfortran.dg/bounds_check_19.f90 : New test.
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, fortran] PR52162 - Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
2018-01-11 17:20 ` Paul Richard Thomas
@ 2018-01-11 17:26 ` Steve Kargl
0 siblings, 0 replies; 3+ messages in thread
From: Steve Kargl @ 2018-01-11 17:26 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: fortran, gcc-patches
On Thu, Jan 11, 2018 at 05:20:35PM +0000, Paul Richard Thomas wrote:
> Ping!
>
OK
--
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-11 17:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-08 14:36 [Patch, fortran] PR52162 - Bogus -fcheck=bounds with realloc on assignment to unallocated LHS Paul Richard Thomas
2018-01-11 17:20 ` Paul Richard Thomas
2018-01-11 17:26 ` Steve Kargl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).