public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/69360] loop optimization produces invalid code when a common array has dimension 1 in some files
Date: Fri, 23 Apr 2021 01:32:45 +0000	[thread overview]
Message-ID: <bug-69360-4-BUSCLTlGa3@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-69360-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Apr 22, 2021 at 10:20:54PM +0000, johnnorthall263 at gmail dot com
wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69360
> 
> --- Comment #6 from John Northall <johnnorthall263 at gmail dot com> ---
> It's deliberate!  I think with this level of understanding of fortran use
> in the real world commercial compilers have a bright future!

I'm commercial compiler do have bright future.  Of course, with 
commercial compiler and a license with paid user support, a 
commercial vendor will gladly deal with garbage-in code. 

> If it works with dimension set to 2 (whatever the background
> true value) then it must be easy to make it do so with
> dimension 1?

>From the Fortran 2018 standard,

R873 common-stmt  is COMMON
       [ / [ common-block-name ] / ] common-block-object-list

R874 common-block-object  is variable-name [ ( array-spec ) ]

C8117 (R874) An array-spec in a common-block-object shall be
      an explicit-shape-spec-list.

R816 explicit-shape-spec  is [ lower-bound : ] upper-bound

This is nearly identical to the language in the Fortran 95 standard. 

This statement in setmid.f

      COMMON /SPACE/ XY(1),XYM(1)

is telling gfortran that the array has an upper bound of 1.  Changing
the above statement to have XY(2), XYM(2) does not mean it works.  It
means you got luck with processor defined behavior.  You simply get
a different error message if you ask your Fortran compiler to help
you debug your code.

% ./example1
At line 21 of file setmid.f
Fortran runtime error: Index '155' of dimension 1 of array 'xym' above upper
bound of 2

As to "it must be easy to make it do so with dimension 1", you 
forgot to attach your patch.  gfortran isn't a commercial compiler.
It depends on contributions for volunteers such as yourself,

      parent reply	other threads:[~2021-04-23  1:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-69360-4@http.gcc.gnu.org/bugzilla/>
2021-04-16 21:17 ` pinskia at gcc dot gnu.org
2021-04-16 22:36 ` johnnorthall263 at gmail dot com
2021-04-17  1:07 ` kargl at gcc dot gnu.org
2021-04-22 22:20 ` johnnorthall263 at gmail dot com
2021-04-23  1:32 ` sgk at troutmask dot apl.washington.edu [this message]

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-69360-4-BUSCLTlGa3@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).