public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/112316] New: [13 Regression] Fix for PR87477 rejects valid code with a bogus error about pointer assignment and causes an ICE
@ 2023-10-31 15:17 trnka at scm dot com
  2023-11-02  8:27 ` [Bug fortran/112316] [13 Regression] Fix for PR87477 rejects valid code with a bogus error about pointer assignment and causes an ICE since r13-7761-gd6997a5aab7aaa325946a6283bfee8ac2bd9f540 rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: trnka at scm dot com @ 2023-10-31 15:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112316

            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 using
gfortran -c test-bogus-pointer-arg-error.f90):

===== test-bogus-pointer-arg-error.f90 =====
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 => z(1))
      end associate

   end subroutine

end module
==========

   14 |       call B (x)
      |              1
Error: Actual argument for ‘y’ 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 routines
A and B need to be present to trigger the issue. It also seems to only happen
when "x" is polymorphic (class(AType)).

A related testcase is also rejected, this time with an ICE:

===== test-ICE-get_descriptor_field.f90 =====
module AModule
   implicit none
   private

   public AType

   type, abstract :: AType
   contains
      generic, public :: assignment(=) => 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 => x(1))
         y = xxx
      end associate
   end subroutine

end module ICEGetDescriptorField
==========

test-ICE-get_descriptor_field.f90:38:16:

   38 |          y = 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 assignment
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 <pault@gcc.gnu.org>
Date:   Sun Aug 27 09:51:32 2023 +0100

    Fortran: Fix some problems blocking associate meta-bug [PR87477]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-03  6:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-31 15:17 [Bug fortran/112316] New: [13 Regression] Fix for PR87477 rejects valid code with a bogus error about pointer assignment and causes an ICE trnka at scm dot com
2023-11-02  8:27 ` [Bug fortran/112316] [13 Regression] Fix for PR87477 rejects valid code with a bogus error about pointer assignment and causes an ICE since r13-7761-gd6997a5aab7aaa325946a6283bfee8ac2bd9f540 rguenth at gcc dot gnu.org
2023-11-02 17:56 ` pault at gcc dot gnu.org
2023-11-02 22:23 ` cvs-commit at gcc dot gnu.org
2023-11-03  6:24 ` cvs-commit at gcc dot gnu.org
2023-11-03  6:29 ` pault at gcc dot gnu.org

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).