public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression
@ 2022-12-15 17:16 jb at gcc dot gnu.org
  2022-12-15 17:41 ` [Bug fortran/108131] [10/11/12/13 Regression] " anlauf at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: jb at gcc dot gnu.org @ 2022-12-15 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108131
           Summary: Incorrect bound calculation when bound intrinsic used
                    in size expression
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jb at gcc dot gnu.org
  Target Milestone: ---

This is from
https://stackoverflow.com/questions/74814027/where-to-report-possible-gfortran-compiler-bug
. Consider

program test
  integer, parameter :: mg(0:10) = 0
  integer, parameter :: u = ubound(mg, dim=1)
  integer, parameter :: cx(-1:ubound(mg, dim=1)) = 1
  integer, parameter :: cy(-1:10) = 2
  integer, parameter :: cz(-1:u) = 3

  write(*,*) lbound(mg, dim=1), ubound(mg, dim=1)
  write(*,*) lbound(cx, dim=1), ubound(cx, dim=1)
  write(*,*) lbound(cy, dim=1), ubound(cy, dim=1)
  write(*,*) lbound(cz, dim=1), ubound(cz, dim=1)
end program test

Obviously the ubounds of all the 4 arrays should be 10. However running the
program results in:

$ ./a.out
           0          10
          -1          11
          -1          10
          -1          10

This affects master as of today, an earlier 12.x snapshot I had lying around,
and 11.3.0 as shipped with Ubuntu 22.04. Based on a comment on the
stackoverflow question, versions 7, 8, 9, and 10 are ok. Looking at
-fdump-tree-original output, the error occurs already in the gfortran frontend.

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

* [Bug fortran/108131] [10/11/12/13 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
@ 2022-12-15 17:41 ` anlauf at gcc dot gnu.org
  2022-12-15 17:47 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-15 17:41 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|Incorrect bound calculation |[10/11/12/13 Regression]
                   |when bound intrinsic used   |Incorrect bound calculation
                   |in size expression          |when bound intrinsic used
                   |                            |in size expression
   Last reconfirmed|                            |2022-12-15
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |anlauf at gcc dot gnu.org
      Known to work|                            |7.5.0, 8.5.0, 9.5.0
      Known to fail|                            |10.4.1, 11.3.1, 12.2.1,
                   |                            |13.0

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.

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

* [Bug fortran/108131] [10/11/12/13 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
  2022-12-15 17:41 ` [Bug fortran/108131] [10/11/12/13 Regression] " anlauf at gcc dot gnu.org
@ 2022-12-15 17:47 ` rguenth at gcc dot gnu.org
  2022-12-15 21:43 ` anlauf at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-12-15 17:47 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.5
           Priority|P3                          |P4

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

* [Bug fortran/108131] [10/11/12/13 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
  2022-12-15 17:41 ` [Bug fortran/108131] [10/11/12/13 Regression] " anlauf at gcc dot gnu.org
  2022-12-15 17:47 ` rguenth at gcc dot gnu.org
@ 2022-12-15 21:43 ` anlauf at gcc dot gnu.org
  2022-12-17 21:22 ` anlauf at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-15 21:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
Possibly caused by the fix for pr103505 (commit r12-5779).

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

* [Bug fortran/108131] [10/11/12/13 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-12-15 21:43 ` anlauf at gcc dot gnu.org
@ 2022-12-17 21:22 ` anlauf at gcc dot gnu.org
  2022-12-23 21:24 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-17 21:22 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |10.3.0
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org

--- Comment #3 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-December/058653.html

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

* [Bug fortran/108131] [10/11/12/13 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-12-17 21:22 ` anlauf at gcc dot gnu.org
@ 2022-12-23 21:24 ` cvs-commit at gcc dot gnu.org
  2022-12-28 16:12 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-23 21:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:6a95f0e0a06d78d94138d4c3dd64d41591197281

commit r13-4880-g6a95f0e0a06d78d94138d4c3dd64d41591197281
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Dec 17 22:04:32 2022 +0100

    Fortran: incorrect array bounds when bound intrinsic used in decl
[PR108131]

    gcc/fortran/ChangeLog:

            PR fortran/108131
            * array.cc (match_array_element_spec): Avoid too early
simplification
            of matched array element specs that can lead to a misinterpretation
            when used as array bounds in array declarations.

    gcc/testsuite/ChangeLog:

            PR fortran/108131
            * gfortran.dg/pr103505.f90: Adjust expected patterns.
            * gfortran.dg/pr108131.f90: New test.

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

* [Bug fortran/108131] [10/11/12/13 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-12-23 21:24 ` cvs-commit at gcc dot gnu.org
@ 2022-12-28 16:12 ` cvs-commit at gcc dot gnu.org
  2022-12-28 16:27 ` [Bug fortran/108131] [10/11 " anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-28 16:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:f97f032f28b3f875e50000061d6b9d7ecf35897a

commit r12-9017-gf97f032f28b3f875e50000061d6b9d7ecf35897a
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Dec 17 22:04:32 2022 +0100

    Fortran: incorrect array bounds when bound intrinsic used in decl
[PR108131]

    gcc/fortran/ChangeLog:

            PR fortran/108131
            * array.cc (match_array_element_spec): Avoid too early
simplification
            of matched array element specs that can lead to a misinterpretation
            when used as array bounds in array declarations.

    gcc/testsuite/ChangeLog:

            PR fortran/108131
            * gfortran.dg/pr103505.f90: Adjust expected patterns.
            * gfortran.dg/pr108131.f90: New test.

    (cherry picked from commit 6a95f0e0a06d78d94138d4c3dd64d41591197281)

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

* [Bug fortran/108131] [10/11 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-12-28 16:12 ` cvs-commit at gcc dot gnu.org
@ 2022-12-28 16:27 ` anlauf at gcc dot gnu.org
  2023-01-08 20:52 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-28 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12/13 Regression]    |[10/11 Regression]
                   |Incorrect bound calculation |Incorrect bound calculation
                   |when bound intrinsic used   |when bound intrinsic used
                   |in size expression          |in size expression

--- Comment #6 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-13, and on 12-branch so far.  Adjusting summary.

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

* [Bug fortran/108131] [10/11 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-12-28 16:27 ` [Bug fortran/108131] [10/11 " anlauf at gcc dot gnu.org
@ 2023-01-08 20:52 ` cvs-commit at gcc dot gnu.org
  2023-01-08 20:56 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-08 20:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:04310741924e7e6ef1ec637a1a9c3e2972345926

commit r11-10458-g04310741924e7e6ef1ec637a1a9c3e2972345926
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Dec 17 22:04:32 2022 +0100

    Fortran: incorrect array bounds when bound intrinsic used in decl
[PR108131]

    gcc/fortran/ChangeLog:

            PR fortran/108131
            * array.c (match_array_element_spec): Avoid too early
simplification
            of matched array element specs that can lead to a misinterpretation
            when used as array bounds in array declarations.

    gcc/testsuite/ChangeLog:

            PR fortran/108131
            * gfortran.dg/pr103505.f90: Adjust expected patterns.
            * gfortran.dg/pr108131.f90: New test.

    (cherry picked from commit 6a95f0e0a06d78d94138d4c3dd64d41591197281)

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

* [Bug fortran/108131] [10/11 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-01-08 20:52 ` cvs-commit at gcc dot gnu.org
@ 2023-01-08 20:56 ` cvs-commit at gcc dot gnu.org
  2023-01-08 20:59 ` anlauf at gcc dot gnu.org
  2023-04-09  2:16 ` jvdelisle at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-08 20:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:ba5012875bc6f7910be3b5cce03e000aa9322c1f

commit r10-11155-gba5012875bc6f7910be3b5cce03e000aa9322c1f
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Dec 17 22:04:32 2022 +0100

    Fortran: incorrect array bounds when bound intrinsic used in decl
[PR108131]

    gcc/fortran/ChangeLog:

            PR fortran/108131
            * array.c (match_array_element_spec): Avoid too early
simplification
            of matched array element specs that can lead to a misinterpretation
            when used as array bounds in array declarations.

    gcc/testsuite/ChangeLog:

            PR fortran/108131
            * gfortran.dg/pr103505.f90: Adjust expected patterns.
            * gfortran.dg/pr108131.f90: New test.

    (cherry picked from commit 6a95f0e0a06d78d94138d4c3dd64d41591197281)

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

* [Bug fortran/108131] [10/11 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2023-01-08 20:56 ` cvs-commit at gcc dot gnu.org
@ 2023-01-08 20:59 ` anlauf at gcc dot gnu.org
  2023-04-09  2:16 ` jvdelisle at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-01-08 20:59 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from anlauf at gcc dot gnu.org ---
Fixed on all open branches.  Closing.

Thanks for the report!

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

* [Bug fortran/108131] [10/11 Regression] Incorrect bound calculation when bound intrinsic used in size expression
  2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2023-01-08 20:59 ` anlauf at gcc dot gnu.org
@ 2023-04-09  2:16 ` jvdelisle at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-04-09  2:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org

--- Comment #10 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
*** Bug 109453 has been marked as a duplicate of this bug. ***

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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 17:16 [Bug fortran/108131] New: Incorrect bound calculation when bound intrinsic used in size expression jb at gcc dot gnu.org
2022-12-15 17:41 ` [Bug fortran/108131] [10/11/12/13 Regression] " anlauf at gcc dot gnu.org
2022-12-15 17:47 ` rguenth at gcc dot gnu.org
2022-12-15 21:43 ` anlauf at gcc dot gnu.org
2022-12-17 21:22 ` anlauf at gcc dot gnu.org
2022-12-23 21:24 ` cvs-commit at gcc dot gnu.org
2022-12-28 16:12 ` cvs-commit at gcc dot gnu.org
2022-12-28 16:27 ` [Bug fortran/108131] [10/11 " anlauf at gcc dot gnu.org
2023-01-08 20:52 ` cvs-commit at gcc dot gnu.org
2023-01-08 20:56 ` cvs-commit at gcc dot gnu.org
2023-01-08 20:59 ` anlauf 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).