public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110658] New: MINVAL/MAXVAL and deferred-length character arrays
@ 2023-07-13 18:26 anlauf at gcc dot gnu.org
  2023-07-16 19:34 ` [Bug fortran/110658] " anlauf at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-07-13 18:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110658
           Summary: MINVAL/MAXVAL and deferred-length character arrays
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

Spin-off from pr110288:

program p
  character(len=2), allocatable :: fixed(:)
  character(len=:), allocatable :: array(:)
  fixed = ["bb", "aa"]
  array = ["bb", "aa"]
  print *, minval (fixed) ! OK
  print *, maxval (array) ! runtime error
end

While the MINVAL for the fixed-length character array works fine,
the MAXVAL for the deferred-length character array gives at runtime:

a.out: ../../../gcc-trunk/libgfortran/generated/maxval0_s1.c:68: maxval0_s1:
Assertion `xlen == len' failed.

All versions since gcc-8 (when MINVAL/MAXVAL of character was implemented)
fail.

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

* [Bug fortran/110658] MINVAL/MAXVAL and deferred-length character arrays
  2023-07-13 18:26 [Bug fortran/110658] New: MINVAL/MAXVAL and deferred-length character arrays anlauf at gcc dot gnu.org
@ 2023-07-16 19:34 ` anlauf at gcc dot gnu.org
  2023-07-16 20:31 ` anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-07-16 19:34 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-07-16
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from anlauf at gcc dot gnu.org ---
I am testing the following patch:

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index dbb04f8c434..e783dbb64b1 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -7654,7 +7654,12 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
             (and other intrinsics?) and dummy functions.  In the case of
SPREAD,
             we take the character length of the first argument for the result.
             For dummies, we have to look through the formal argument list for
-            this function and use the character length found there.*/
+            this function and use the character length found there.
+            Likewise, we handle the case of deferred-length character dummy
+            arguments to intrinsics that determine the characteristics of
+            the result, which cannot be deferred-length.  */
+         if (expr->value.function.isym)
+           ts.deferred = false;
          if (ts.deferred)
            cl.backend_decl = gfc_create_var (gfc_charlen_type_node, "slen");
          else if (!sym->attr.dummy)

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

* [Bug fortran/110658] MINVAL/MAXVAL and deferred-length character arrays
  2023-07-13 18:26 [Bug fortran/110658] New: MINVAL/MAXVAL and deferred-length character arrays anlauf at gcc dot gnu.org
  2023-07-16 19:34 ` [Bug fortran/110658] " anlauf at gcc dot gnu.org
@ 2023-07-16 20:31 ` anlauf at gcc dot gnu.org
  2023-07-17 18:49 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-07-16 20:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2023-July/059620.html

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

* [Bug fortran/110658] MINVAL/MAXVAL and deferred-length character arrays
  2023-07-13 18:26 [Bug fortran/110658] New: MINVAL/MAXVAL and deferred-length character arrays anlauf at gcc dot gnu.org
  2023-07-16 19:34 ` [Bug fortran/110658] " anlauf at gcc dot gnu.org
  2023-07-16 20:31 ` anlauf at gcc dot gnu.org
@ 2023-07-17 18:49 ` cvs-commit at gcc dot gnu.org
  2023-07-18 18:40 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-17 18:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:95ddd2659849a904509067ec3a2770135149a722

commit r14-2586-g95ddd2659849a904509067ec3a2770135149a722
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Jul 16 22:17:27 2023 +0200

    Fortran: intrinsics and deferred-length character arguments
[PR95947,PR110658]

    gcc/fortran/ChangeLog:

            PR fortran/95947
            PR fortran/110658
            * trans-expr.cc (gfc_conv_procedure_call): For intrinsic procedures
            whose result characteristics depends on the first argument and
which
            can be of type character, the character length will not be
deferred.

    gcc/testsuite/ChangeLog:

            PR fortran/95947
            PR fortran/110658
            * gfortran.dg/deferred_character_37.f90: New test.

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

* [Bug fortran/110658] MINVAL/MAXVAL and deferred-length character arrays
  2023-07-13 18:26 [Bug fortran/110658] New: MINVAL/MAXVAL and deferred-length character arrays anlauf at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-07-17 18:49 ` cvs-commit at gcc dot gnu.org
@ 2023-07-18 18:40 ` cvs-commit at gcc dot gnu.org
  2023-07-20 18:56 ` 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 @ 2023-07-18 18:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r13-7584-gccf94ab2abb6969c04d51c7879f07edfbb97ae55
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Jul 16 22:17:27 2023 +0200

    Fortran: intrinsics and deferred-length character arguments
[PR95947,PR110658]

    gcc/fortran/ChangeLog:

            PR fortran/95947
            PR fortran/110658
            * trans-expr.cc (gfc_conv_procedure_call): For intrinsic procedures
            whose result characteristics depends on the first argument and
which
            can be of type character, the character length will not be
deferred.

    gcc/testsuite/ChangeLog:

            PR fortran/95947
            PR fortran/110658
            * gfortran.dg/deferred_character_37.f90: New test.

    (cherry picked from commit 95ddd2659849a904509067ec3a2770135149a722)

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

* [Bug fortran/110658] MINVAL/MAXVAL and deferred-length character arrays
  2023-07-13 18:26 [Bug fortran/110658] New: MINVAL/MAXVAL and deferred-length character arrays anlauf at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-07-18 18:40 ` cvs-commit at gcc dot gnu.org
@ 2023-07-20 18:56 ` cvs-commit at gcc dot gnu.org
  2023-07-20 19:06 ` cvs-commit at gcc dot gnu.org
  2023-07-20 19:06 ` anlauf at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-20 18:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:5279d2db0c4ace4f8d311d9c875d51a0fe7b40ea

commit r12-9782-g5279d2db0c4ace4f8d311d9c875d51a0fe7b40ea
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Jul 16 22:17:27 2023 +0200

    Fortran: intrinsics and deferred-length character arguments
[PR95947,PR110658]

    gcc/fortran/ChangeLog:

            PR fortran/95947
            PR fortran/110658
            * trans-expr.cc (gfc_conv_procedure_call): For intrinsic procedures
            whose result characteristics depends on the first argument and
which
            can be of type character, the character length will not be
deferred.

    gcc/testsuite/ChangeLog:

            PR fortran/95947
            PR fortran/110658
            * gfortran.dg/deferred_character_37.f90: New test.

    (cherry picked from commit 95ddd2659849a904509067ec3a2770135149a722)

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

* [Bug fortran/110658] MINVAL/MAXVAL and deferred-length character arrays
  2023-07-13 18:26 [Bug fortran/110658] New: MINVAL/MAXVAL and deferred-length character arrays anlauf at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-07-20 18:56 ` cvs-commit at gcc dot gnu.org
@ 2023-07-20 19:06 ` cvs-commit at gcc dot gnu.org
  2023-07-20 19:06 ` anlauf at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-20 19:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:7bd1373f87d581b1e5482f9c558d481c38027a99

commit r11-10918-g7bd1373f87d581b1e5482f9c558d481c38027a99
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Jul 16 22:17:27 2023 +0200

    Fortran: intrinsics and deferred-length character arguments
[PR95947,PR110658]

    gcc/fortran/ChangeLog:

            PR fortran/95947
            PR fortran/110658
            * trans-expr.c (gfc_conv_procedure_call): For intrinsic procedures
            whose result characteristics depends on the first argument and
which
            can be of type character, the character length will not be
deferred.

    gcc/testsuite/ChangeLog:

            PR fortran/95947
            PR fortran/110658
            * gfortran.dg/deferred_character_37.f90: New test.

    (cherry picked from commit 95ddd2659849a904509067ec3a2770135149a722)

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

* [Bug fortran/110658] MINVAL/MAXVAL and deferred-length character arrays
  2023-07-13 18:26 [Bug fortran/110658] New: MINVAL/MAXVAL and deferred-length character arrays anlauf at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-07-20 19:06 ` cvs-commit at gcc dot gnu.org
@ 2023-07-20 19:06 ` anlauf at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-07-20 19:06 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |11.5

--- Comment #7 from anlauf at gcc dot gnu.org ---
Fixed.

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

end of thread, other threads:[~2023-07-20 19:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-13 18:26 [Bug fortran/110658] New: MINVAL/MAXVAL and deferred-length character arrays anlauf at gcc dot gnu.org
2023-07-16 19:34 ` [Bug fortran/110658] " anlauf at gcc dot gnu.org
2023-07-16 20:31 ` anlauf at gcc dot gnu.org
2023-07-17 18:49 ` cvs-commit at gcc dot gnu.org
2023-07-18 18:40 ` cvs-commit at gcc dot gnu.org
2023-07-20 18:56 ` cvs-commit at gcc dot gnu.org
2023-07-20 19:06 ` cvs-commit at gcc dot gnu.org
2023-07-20 19:06 ` anlauf 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).