public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/115150] New: [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value
@ 2024-05-18 16:12 burnus at gcc dot gnu.org
  2024-05-18 16:36 ` [Bug fortran/115150] " burnus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2024-05-18 16:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115150
           Summary: [12/13/14/15 Regression] SHAPE of zero-sized array
                    yields a negative value
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

GCC 11.4 has:
 Shape:           0           0
 Shape:           0           3           0

But since GCC 12:
 Shape:          -2           0
 Shape:          -3           3           0

Testcase:

implicit none
real,allocatable :: A(:),B(:,:)
allocate(a(3:0), b(5:1, 3))
print *, 'Shape:', shape(a), size(a)
print *, 'Shape:', shape(b), size(b)
end

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

* [Bug fortran/115150] [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value
  2024-05-18 16:12 [Bug fortran/115150] New: [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value burnus at gcc dot gnu.org
@ 2024-05-18 16:36 ` burnus at gcc dot gnu.org
  2024-05-20  6:35 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2024-05-18 16:36 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.5
                 CC|                            |sandra at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Looking at the dump, GCC 11 has:
      _gfortran_shape_4 (&parm.3, D.3966);
while GCC 12 has:
      x[S.3] = (integer(kind=4)) (((unsigned int) a.dim[S.3].ubound - (unsigned
int) a.dim[S.3].lbound) + 1);

* * * *

Probably caused by:

r12-4591-g1af78e731feb93
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Tue Oct 19 21:11:15 2021 -0700

    Fortran: Fixes and additional tests for shape/ubound/size [PR94070]

    This patch reimplements the SHAPE intrinsic to be inlined similarly to
    LBOUND and UBOUND, instead of as a library call, to avoid an
    unnecessary array copy.  Various bugs are also fixed.

    gcc/fortran/
            PR fortran/94070

* * *

SHAPE has:
"Result Value. The result has a value whose i-th element is equal to the extent
of dimension i of SOURCE, except that if SOURCE is assumed-rank, and associated
with an assumed-size array, the last element is equal to −1."

Thus, an example for the latter:

GCC 11.4 - good:
           0           2          -1
GCC 12 (to trunk) - wrong:
          -3           2          -1

integer :: x(10)
call f(x, -3)
contains
subroutine f(y,n)
  integer :: y(1:n,2,*)
  call g(y)
end
subroutine g(z)
  integer :: z(..)
  print *, shape(z)
end
end

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

* [Bug fortran/115150] [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value
  2024-05-18 16:12 [Bug fortran/115150] New: [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value burnus at gcc dot gnu.org
  2024-05-18 16:36 ` [Bug fortran/115150] " burnus at gcc dot gnu.org
@ 2024-05-20  6:35 ` cvs-commit at gcc dot gnu.org
  2024-05-21 15:22 ` [Bug fortran/115150] [12/13/14 " pault at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-20  6:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

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

commit r15-658-gb701306a9b38bd74cdc26c7ece5add22f2203b56
Author: Tobias Burnus <tburnus@baylibre.com>
Date:   Mon May 20 08:34:48 2024 +0200

    Fortran: Fix SHAPE for zero-size arrays

            PR fortran/115150

    gcc/fortran/ChangeLog:

            * trans-intrinsic.cc (gfc_conv_intrinsic_bound): Fix SHAPE
            for zero-size arrays

    gcc/testsuite/ChangeLog:

            * gfortran.dg/shape_12.f90: New test.

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

* [Bug fortran/115150] [12/13/14 Regression] SHAPE of zero-sized array yields a negative value
  2024-05-18 16:12 [Bug fortran/115150] New: [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value burnus at gcc dot gnu.org
  2024-05-18 16:36 ` [Bug fortran/115150] " burnus at gcc dot gnu.org
  2024-05-20  6:35 ` cvs-commit at gcc dot gnu.org
@ 2024-05-21 15:22 ` pault at gcc dot gnu.org
  2024-05-28 13:00 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2024-05-21 15:22 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
            Summary|[12/13/14/15 Regression]    |[12/13/14 Regression] SHAPE
                   |SHAPE of zero-sized array   |of zero-sized array yields
                   |yields a negative value     |a negative value
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |pault at gcc dot gnu.org
   Last reconfirmed|                            |2024-05-21

--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to GCC Commits from comment #2)
> The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:
> 
> https://gcc.gnu.org/g:b701306a9b38bd74cdc26c7ece5add22f2203b56
> 
> commit r15-658-gb701306a9b38bd74cdc26c7ece5add22f2203b56
> Author: Tobias Burnus <tburnus@baylibre.com>
> Date:   Mon May 20 08:34:48 2024 +0200
> 
>     Fortran: Fix SHAPE for zero-size arrays
>     
>             PR fortran/115150
>     
>     gcc/fortran/ChangeLog:
>     
>             * trans-intrinsic.cc (gfc_conv_intrinsic_bound): Fix SHAPE
>             for zero-size arrays
>     
>     gcc/testsuite/ChangeLog:
>     
>             * gfortran.dg/shape_12.f90: New test.

Hi Tobias,

Good call! I take it that you will backport?

Thanks

Paul

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

* [Bug fortran/115150] [12/13/14 Regression] SHAPE of zero-sized array yields a negative value
  2024-05-18 16:12 [Bug fortran/115150] New: [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-05-21 15:22 ` [Bug fortran/115150] [12/13/14 " pault at gcc dot gnu.org
@ 2024-05-28 13:00 ` cvs-commit at gcc dot gnu.org
  2024-05-28 14:57 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-28 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Tobias Burnus
<burnus@gcc.gnu.org>:

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

commit r14-10251-gdbeb3d127da07963ecaa26680da62a255199e9c2
Author: Tobias Burnus <tburnus@baylibre.com>
Date:   Mon May 20 08:34:48 2024 +0200

    Fortran: Fix SHAPE for zero-size arrays

            PR fortran/115150

    gcc/fortran/ChangeLog:

            * trans-intrinsic.cc (gfc_conv_intrinsic_bound): Fix SHAPE
            for zero-size arrays

    gcc/testsuite/ChangeLog:

            * gfortran.dg/shape_12.f90: New test.

    (cherry picked from commit b701306a9b38bd74cdc26c7ece5add22f2203b56)

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

* [Bug fortran/115150] [12/13/14 Regression] SHAPE of zero-sized array yields a negative value
  2024-05-18 16:12 [Bug fortran/115150] New: [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-05-28 13:00 ` cvs-commit at gcc dot gnu.org
@ 2024-05-28 14:57 ` cvs-commit at gcc dot gnu.org
  2024-05-28 16:51 ` cvs-commit at gcc dot gnu.org
  2024-05-28 16:52 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-28 14:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Tobias Burnus
<burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:3185cfe495944e6e5d000ccd820bed2e6f10cd6c

commit r13-8805-g3185cfe495944e6e5d000ccd820bed2e6f10cd6c
Author: Tobias Burnus <tburnus@baylibre.com>
Date:   Mon May 20 08:34:48 2024 +0200

    Fortran: Fix SHAPE for zero-size arrays

            PR fortran/115150

    gcc/fortran/ChangeLog:

            * trans-intrinsic.cc (gfc_conv_intrinsic_bound): Fix SHAPE
            for zero-size arrays

    gcc/testsuite/ChangeLog:

            * gfortran.dg/shape_12.f90: New test.

    (cherry picked from commit b701306a9b38bd74cdc26c7ece5add22f2203b56)

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

* [Bug fortran/115150] [12/13/14 Regression] SHAPE of zero-sized array yields a negative value
  2024-05-18 16:12 [Bug fortran/115150] New: [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-05-28 14:57 ` cvs-commit at gcc dot gnu.org
@ 2024-05-28 16:51 ` cvs-commit at gcc dot gnu.org
  2024-05-28 16:52 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-28 16:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Tobias Burnus
<burnus@gcc.gnu.org>:

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

commit r12-10476-ge0b2c4f90f908a9bca4038c7ae0d8ca6ee157d8f
Author: Tobias Burnus <tburnus@baylibre.com>
Date:   Mon May 20 08:34:48 2024 +0200

    Fortran: Fix SHAPE for zero-size arrays

            PR fortran/115150

    gcc/fortran/ChangeLog:

            * trans-intrinsic.cc (gfc_conv_intrinsic_bound): Fix SHAPE
            for zero-size arrays

    gcc/testsuite/ChangeLog:

            * gfortran.dg/shape_12.f90: New test.

    (cherry picked from commit b701306a9b38bd74cdc26c7ece5add22f2203b56)

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

* [Bug fortran/115150] [12/13/14 Regression] SHAPE of zero-sized array yields a negative value
  2024-05-18 16:12 [Bug fortran/115150] New: [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-05-28 16:51 ` cvs-commit at gcc dot gnu.org
@ 2024-05-28 16:52 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2024-05-28 16:52 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

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

--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED on all affected branches.

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

end of thread, other threads:[~2024-05-28 16:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-18 16:12 [Bug fortran/115150] New: [12/13/14/15 Regression] SHAPE of zero-sized array yields a negative value burnus at gcc dot gnu.org
2024-05-18 16:36 ` [Bug fortran/115150] " burnus at gcc dot gnu.org
2024-05-20  6:35 ` cvs-commit at gcc dot gnu.org
2024-05-21 15:22 ` [Bug fortran/115150] [12/13/14 " pault at gcc dot gnu.org
2024-05-28 13:00 ` cvs-commit at gcc dot gnu.org
2024-05-28 14:57 ` cvs-commit at gcc dot gnu.org
2024-05-28 16:51 ` cvs-commit at gcc dot gnu.org
2024-05-28 16:52 ` burnus 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).