From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BA2723858D1E; Tue, 31 Oct 2023 15:17:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA2723858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698765471; bh=sViUuv43EoofyxqR2pO4XS6W031xWWgD+j5oxstD09o=; h=From:To:Subject:Date:From; b=OhjquGdXwniZYhSdLE2/nL12EI0KJbmekEb1JgXh57xAH5CQfSOoEcNwdM/DhLr2z 5bc4sZZhkEsGnCB00MK00AHJoCCxAjQZ8rz9mkV6IPqY48iJNQDJkgUxjxcXtrLz0k 7XAaGY5fHo5MQrO2BvjqN0dw334BjRmpXyu0vL8A= From: "trnka at scm dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/112316] New: [13 Regression] Fix for PR87477 rejects valid code with a bogus error about pointer assignment and causes an ICE Date: Tue, 31 Oct 2023 15:17:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: trnka at scm dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112316 Bug ID: 112316 Summary: [13 Regression] Fix for PR87477 rejects valid code with a bogus error about pointer assignment and causes an ICE Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: trnka at scm dot com Target Milestone: --- Current releases/gcc-13 rejects the following testcase (compiled simply usi= ng gfortran -c test-bogus-pointer-arg-error.f90): =3D=3D=3D=3D=3D test-bogus-pointer-arg-error.f90 =3D=3D=3D=3D=3D module BogusPointerArgError implicit none type :: AType end type contains subroutine A () class(AType), allocatable :: x allocate(x) call B (x) end subroutine subroutine B (y) class(AType), intent(in) :: y end subroutine subroutine C (z) class(AType), intent(in) :: z(:) associate (xxx =3D> z(1)) end associate end subroutine end module =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 14 | call B (x) | 1 Error: Actual argument for =E2=80=98y=E2=80=99 at (1) must be a pointer or = a valid target for the dummy pointer in a pointer assignment statement Apparently, both the associate block in C (which is never called) and routi= nes A and B need to be present to trigger the issue. It also seems to only happ= en when "x" is polymorphic (class(AType)). A related testcase is also rejected, this time with an ICE: =3D=3D=3D=3D=3D test-ICE-get_descriptor_field.f90 =3D=3D=3D=3D=3D module AModule implicit none private public AType type, abstract :: AType contains generic, public :: assignment(=3D) =3D> Assign procedure, private :: Assign end type AType contains subroutine Assign(lhs, rhs) class(AType), intent(inout) :: lhs class(AType), intent(in) :: rhs end subroutine end module AModule module ICEGetDescriptorField use AModule implicit none contains subroutine Foo (x) class(AType), intent(in) :: x(:) class(AType), allocatable :: y associate (xxx =3D> x(1)) y =3D xxx end associate end subroutine end module ICEGetDescriptorField =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D test-ICE-get_descriptor_field.f90:38:16: 38 | y =3D xxx | 1 internal compiler error: in gfc_get_descriptor_field, at fortran/trans-array.cc:245 This time, AType needs to be in a separate module and have a defined assign= ment to trigger the bug. Both issues bisect to the following commit. Reverting this change on top of current releases/gcc-13 makes both issues go away. (GCC 14 is likely also affected, not tested.) https://gcc.gnu.org/g:d6997a5aab7aaa325946a6283bfee8ac2bd9f540 commit r13-7761-gd6997a5aab7aaa325946a6283bfee8ac2bd9f540 Author: Paul Thomas Date: Sun Aug 27 09:51:32 2023 +0100 Fortran: Fix some problems blocking associate meta-bug [PR87477]=