public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jvdelisle at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/109453] New: UBOUND incorrect when used in declartion of another array
Date: Sun, 09 Apr 2023 00:02:39 +0000	[thread overview]
Message-ID: <bug-109453-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109453
           Summary: UBOUND incorrect when used in declartion of another
                    array
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jvdelisle at gcc dot gnu.org
  Target Milestone: ---

The following program illustrates:

integer, parameter :: a(0:19)=(/(i,i=0,19)/)
integer :: b(-1:ubound(a,dim=1)) ! <<<< This gives wrong result
! integer, parameter  :: c = ubound(a,dim=1) ! Using an intermediate works
! integer :: b(-1:c) ! Using the intermediate
b(-1:ubound(a,dim=1))=(/0,a(0:19)/)
write(*,'(1000i3)') a
write(*,'(1000i3)') b
print *, rank(b), size(b), ubound(b), lbound(b)
print *, rank(a), size(a), ubound(a), lbound(a)
end

Giving:

$ ./a.out 
  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19
  0  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19  0
           1          22          20          -1
           1          20          19           0

Commenting out the wrong result line and uncommenting the alternate lines:

$ ./a.out 
  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19
  0  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19
           1          21          19          -1
           1          20          19           0

Looks like an off by one somewhere.

             reply	other threads:[~2023-04-09  0:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-09  0:02 jvdelisle at gcc dot gnu.org [this message]
2023-04-09  0:31 ` [Bug fortran/109453] " kargl at gcc dot gnu.org
2023-04-09  0:33 ` kargl at gcc dot gnu.org
2023-04-09  1:25 ` [Bug fortran/109453] [REGRESSION] " jvdelisle at gcc dot gnu.org
2023-04-09  1:42 ` sgk at troutmask dot apl.washington.edu
2023-04-09  1:46 ` jvdelisle at gcc dot gnu.org
2023-04-09  2:16 ` jvdelisle 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-109453-4@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).