public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anlauf at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/113956] [13/14 Regression] ice in gfc_trans_pointer_assignment, at fortran/trans-expr.cc:10524
Date: Fri, 29 Mar 2024 16:37:13 +0000	[thread overview]
Message-ID: <bug-113956-4-ttUizit4V5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113956-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to Paul Thomas from comment #3)
> I can see why the assert is there but it is manifestly wrong for both the
> assumed length target and a constant length.

That's why I wanted to pass this on to you.  I am not sure what the precise
logic should be.

> I was thrown a bit by the
> distros nulling out the asserts so that it compiled just fine with the
> system gfortran.

If the system gfortran is based on 13.2 *release* then the bug is not yet
there ;-)  It entered 13-branch through backport r13-7986.

> Your patch is perfect :- This compiles and runs correctly:
> module m
> contains
>   subroutine test_array_char(p, x)
>     character(*), target  :: x(:)
>     character(:), pointer :: p(:)
>     p => x
>   end subroutine
> end module
> 
>   use m
>   character(:), allocatable, target :: chr(:)
>   character(:), pointer :: p(:)
>   chr = ["ab","cd"]
>   call test_array_char (p, chr)
>   print '(l2,i4,2a4)', loc(chr) == loc(p), len(p), p
> end

The original testcase attached here has a second subroutine that ICEd:

subroutine test_array_char_remap(p, x)
  character(*), target  :: x(100)
  character(:), pointer :: p(:, :)
  p(2:11, 3:12) => x
end subroutine

It is also fixed by the patch, and checking the bounds etc. in the caller
shows that it works correct too :-)

program main
  implicit none
  character(3) :: x(100) = "* #"
  character(:), pointer :: p(:), q(:,:)
  call test_array_char (p, x)
  print *, associated (p)
  print *, size (p)
  print *, len (p)
  print *, p(5)(1:1)
  call test_array_char_remap (q, x)
  print *, associated (q)
  print *, size (q)
  print *, len (q)
  print *, lbound(q), ubound(q)
  print *, q(5,5)(3:3)
contains

subroutine test_array_char(p, x)
  character(*), target  :: x(100)
  character(:), pointer :: p(:)
  p => x
end subroutine

subroutine test_array_char_remap(p, x)
  character(*), target  :: x(100)
  character(:), pointer :: p(:, :)
  p(2:11, 3:12) => x
end subroutine

end

  parent reply	other threads:[~2024-03-29 16:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-16  8:20 [Bug fortran/113956] New: " dcb314 at hotmail dot com
2024-03-29  9:53 ` [Bug fortran/113956] [14 Regression] " dcb314 at hotmail dot com
2024-03-29 12:03 ` [Bug fortran/113956] [13/14 " anlauf at gcc dot gnu.org
2024-03-29 15:35 ` pault at gcc dot gnu.org
2024-03-29 16:37 ` anlauf at gcc dot gnu.org [this message]
2024-04-02 19:19 ` anlauf at gcc dot gnu.org
2024-04-03 13:06 ` pault at gcc dot gnu.org
2024-04-09 14:23 ` cvs-commit at gcc dot gnu.org
2024-04-17 13:34 ` law at gcc dot gnu.org
2024-05-08  8:06 ` [Bug fortran/113956] [13 " cvs-commit at gcc dot gnu.org
2024-05-08  8:08 ` pault at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113956-4-ttUizit4V5@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).