public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: sgk@troutmask.apl.washington.edu
Cc: Jerry D <jvdelisle2@gmail.com>,
	fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix fortran/PR114024
Date: Thu, 22 Feb 2024 22:32:19 +0100	[thread overview]
Message-ID: <36c5afe2-07d5-41b2-8410-721f2a54dd51@gmx.de> (raw)
In-Reply-To: <Zde2PODEkXrVRyRp@troutmask.apl.washington.edu>

On 2/22/24 22:01, Steve Kargl wrote:
> On Thu, Feb 22, 2024 at 09:22:37PM +0100, Harald Anlauf wrote:
>> On the positive side, it not only seems to fix the cases in question,
>> but also substring references etc., like the following:
>
> If the above passes a regression test, then by all means we should
> use it.  I did not consider the substring case.  Even if unneeded
> parentheses are inserted, which may cause generation of a temporary
> variable, I hope users are not using 'allocate(x,source=z%re)' is
> some deeply nested crazy loops structure.

First thing is code correctness.  There are cases where the
allocation shall preserve the array bounds, which is where
we must avoid the parentheses at all cost.  But these cases
should be very limited.  (There are some code comments/TODOs
regarding this and an open PR by Tobias(?)).

The cases we are currently discussing are even requiring(!)
the resetting of the lower bounds to 1, so your suggestion
to enforce parentheses does not look unreasonable.

BTW: If someone uses allocate in a tight loop, he/she deserves
to be punished anyway...

> BTW, my patch and I suspect your improved patch also
> fixes 'allocate(x,mold=z%re)'.  Consider,
>
>     complex z(3)
>     real, allocatable :: x(:)
>     z = 42ha
>     allocate(x, mold=z%re)
>     print *, size(x)
>     end
>
> % gfortran13 -o z a.f90
> a.f90:9:25:
>
>      9 |    allocate(x, mold=z%re)
>        |                         1
> internal compiler error: in retrieve_last_ref, at fortran/trans-array.cc:6070
> 0x247d7a679 __libc_start1
>          /usr/src/lib/libc/csu/libc_start1.c:157
>
> % gfcx -o z a.f90 && ./z
>             3
>

Nice!  I completely forgot about MOLD...

So the only missing pieces are a really comprehensive testcase
and successful regtests...

Cheers,
Harald



  reply	other threads:[~2024-02-22 21:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 18:30 Steve Kargl
2024-02-21 19:41 ` Jerry D
2024-02-21 20:28   ` Harald Anlauf
2024-02-21 20:31     ` Jerry D
2024-02-21 21:00     ` Steve Kargl
2024-02-21 21:20       ` Harald Anlauf
2024-02-21 21:42         ` Steve Kargl
2024-02-22  0:52           ` Steve Kargl
2024-02-22 20:22             ` Harald Anlauf
2024-02-22 21:01               ` Steve Kargl
2024-02-22 21:32                 ` Harald Anlauf [this message]
2024-02-23 21:15                   ` [PATCH, v2] " Harald Anlauf
2024-02-23 21:32                     ` rep.dot.nop
2024-02-23 21:34                     ` Steve Kargl

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=36c5afe2-07d5-41b2-8410-721f2a54dd51@gmx.de \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jvdelisle2@gmail.com \
    --cc=sgk@troutmask.apl.washington.edu \
    /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).