This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/52162] Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
- From: "pault at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 08 Jul 2017 11:44:56 +0000
- Subject: [Bug fortran/52162] Bogus -fcheck=bounds with realloc on assignment to unallocated LHS
- Auto-submitted: auto-generated
- References: <bug-52162-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52162
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pault at gcc dot gnu.org
--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> ---
Changing the line mentioned in comment #2 to:
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;
fixes the problem. This testcase now runs correctly:
! { 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 (int(asin(c)*100.0) .ne. b(9:11))) call abort
deallocate (a, b, c)
end
I will submit as soon as the patch for PR34640 clears my tree.
Paul