public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/109453] New: UBOUND incorrect when used in declartion of another array
@ 2023-04-09  0:02 jvdelisle at gcc dot gnu.org
  2023-04-09  0:31 ` [Bug fortran/109453] " kargl at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-04-09  0:02 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2023-04-09  2:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-09  0:02 [Bug fortran/109453] New: UBOUND incorrect when used in declartion of another array jvdelisle at gcc dot gnu.org
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

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