public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
@ 2021-04-26 19:48 gscfq@t-online.de
  2021-04-26 21:00 ` [Bug fortran/100274] " anlauf at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2021-04-26 19:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100274
           Summary: [9/10/11/12 Regression] ICE in
                    gfc_conv_procedure_call, at fortran/trans-expr.c:6131
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Changed with r9 between 20180916 and 20180923 :
(as a supplement to pr100154)


$ cat z1.f90
program p
   call s('x')
contains
   subroutine s(x)
      character(8), intent(out) :: x
   end
end


$ gfortran-9-20180916 -c z1.f90
z1.f90:2:10:

2 |    call s('x')
  |          1
Warning: Character length of actual argument shorter than of dummy argument 'x'
(1/8) at (1) [-Wargument-mismatch]


$ gfortran-11-20210425 -c z1.f90
z1.f90:2:10:

    2 |    call s('x')
      |          1
Warning: Character length of actual argument shorter than of dummy argument 'x'
(1/8) at (1)
z1.f90:2:14:

    2 |    call s('x')
      |              1
internal compiler error: Segmentation fault
0xc0b78f crash_signal
        ../../gcc/toplev.c:327
0x77206f gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
        ../../gcc/fortran/trans-expr.c:6131
0x7a9ba8 gfc_trans_call(gfc_code*, bool, tree_node*, tree_node*, bool)
        ../../gcc/fortran/trans-stmt.c:424
0x739e38 trans_code
        ../../gcc/fortran/trans.c:2000
0x760094 gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.c:6885
0x6e6a36 translate_all_program_units
        ../../gcc/fortran/parse.c:6355
0x6e6a36 gfc_parse_file()
        ../../gcc/fortran/parse.c:6624
0x732d2f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:212

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

* [Bug fortran/100274] [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
  2021-04-26 19:48 [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131 gscfq@t-online.de
@ 2021-04-26 21:00 ` anlauf at gcc dot gnu.org
  2021-04-27 20:39 ` anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-26 21:00 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.4
           Priority|P3                          |P4
                 CC|                            |anlauf at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-04-26
     Ever confirmed|0                           |1

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

Obvious fix for NULL pointer dereference:

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 213f32b0a67..450ee7e3ae7 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -6128,6 +6128,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                      bool add_clobber;
                      add_clobber = fsym && fsym->attr.intent == INTENT_OUT
                        && !fsym->attr.allocatable && !fsym->attr.pointer
+                       && e->symtree
                        && !e->symtree->n.sym->attr.dimension
                        && !e->symtree->n.sym->attr.pointer
                        && !e->symtree->n.sym->attr.allocatable

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

* [Bug fortran/100274] [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
  2021-04-26 19:48 [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131 gscfq@t-online.de
  2021-04-26 21:00 ` [Bug fortran/100274] " anlauf at gcc dot gnu.org
@ 2021-04-27 20:39 ` anlauf at gcc dot gnu.org
  2021-04-27 20:57 ` anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-27 20:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
The patch in comment#1 would turn the ICE into an accepts-invalid, since
we would only get a warning instead of an error.  This happens because
the character length check in gfc_compare_actual_formal returns too early
after emitting the warning.

The simplest fix would be to continue doing the checking:

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 60736123550..9e3e8aa9da9 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -3255,10 +3255,13 @@ gfc_compare_actual_formal (gfc_actual_arglist **ap,
gfc_formal_arglist *formal,
          && f->sym->attr.flavor != FL_PROCEDURE)
        {
          if (a->expr->ts.type == BT_CHARACTER && !f->sym->as && where)
-           gfc_warning (0, "Character length of actual argument shorter "
-                        "than of dummy argument %qs (%lu/%lu) at %L",
-                        f->sym->name, actual_size, formal_size,
-                        &a->expr->where);
+           {
+             gfc_warning (0, "Character length of actual argument shorter "
+                          "than of dummy argument %qs (%lu/%lu) at %L",
+                          f->sym->name, actual_size, formal_size,
+                          &a->expr->where);
+             goto skip_size_check;
+           }
           else if (where)
            {
              /* Emit a warning for -std=legacy and an error otherwise. */

This regtests cleanly and allows to emit the same error message as for
matching character length.

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

* [Bug fortran/100274] [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
  2021-04-26 19:48 [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131 gscfq@t-online.de
  2021-04-26 21:00 ` [Bug fortran/100274] " anlauf at gcc dot gnu.org
  2021-04-27 20:39 ` anlauf at gcc dot gnu.org
@ 2021-04-27 20:57 ` anlauf at gcc dot gnu.org
  2021-05-05 13:26 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-27 20:57 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #3 from anlauf at gcc dot gnu.org ---
Patch: https://gcc.gnu.org/pipermail/fortran/2021-April/056000.html

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

* [Bug fortran/100274] [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
  2021-04-26 19:48 [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-04-27 20:57 ` anlauf at gcc dot gnu.org
@ 2021-05-05 13:26 ` cvs-commit at gcc dot gnu.org
  2021-05-05 19:00 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-05 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:a8b79cc939d6786293f654c42a2d1b0ab040de0e

commit r12-515-ga8b79cc939d6786293f654c42a2d1b0ab040de0e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed May 5 15:25:50 2021 +0200

    PR fortran/100274 - ICE in gfc_conv_procedure_call, at
fortran/trans-expr.c:6131

    When the check for the length of formal and actual character arguments
    found a mismatch and emitted a warning, it would skip further checks
    like that could lead to errors.  Fix that by continuing the checking.
    Also catch a NULL pointer dereference.

    gcc/fortran/ChangeLog:

            PR fortran/100274
            * interface.c (gfc_compare_actual_formal): Continue checks after
            emitting warning for argument length mismatch.
            * trans-expr.c (gfc_conv_procedure_call): Check for NULL pointer
            dereference.

    gcc/testsuite/ChangeLog:

            PR fortran/100274
            * gfortran.dg/argument_checking_25.f90: New test.

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

* [Bug fortran/100274] [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
  2021-04-26 19:48 [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2021-05-05 13:26 ` cvs-commit at gcc dot gnu.org
@ 2021-05-05 19:00 ` cvs-commit at gcc dot gnu.org
  2021-05-05 19:40 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-05 19:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:ba013672f723f87f0c3b0c685dda5b3b2f1b3f3a

commit r11-8357-gba013672f723f87f0c3b0c685dda5b3b2f1b3f3a
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed May 5 15:25:50 2021 +0200

    PR fortran/100274 - ICE in gfc_conv_procedure_call, at
fortran/trans-expr.c:6131

    When the check for the length of formal and actual character arguments
    found a mismatch and emitted a warning, it would skip further checks
    like that could lead to errors.  Fix that by continuing the checking.
    Also catch a NULL pointer dereference.

    gcc/fortran/ChangeLog:

            PR fortran/100274
            * interface.c (gfc_compare_actual_formal): Continue checks after
            emitting warning for argument length mismatch.
            * trans-expr.c (gfc_conv_procedure_call): Check for NULL pointer
            dereference.

    gcc/testsuite/ChangeLog:

            PR fortran/100274
            * gfortran.dg/argument_checking_25.f90: New test.

    (cherry picked from commit a8b79cc939d6786293f654c42a2d1b0ab040de0e)

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

* [Bug fortran/100274] [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
  2021-04-26 19:48 [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2021-05-05 19:00 ` cvs-commit at gcc dot gnu.org
@ 2021-05-05 19:40 ` cvs-commit at gcc dot gnu.org
  2021-05-05 19:55 ` cvs-commit at gcc dot gnu.org
  2021-05-05 19:59 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-05 19:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

commit r10-9803-g92fef3f29917407a31c58c1c06203e4fbe7d4319
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed May 5 15:25:50 2021 +0200

    PR fortran/100274 - ICE in gfc_conv_procedure_call, at
fortran/trans-expr.c:6131

    When the check for the length of formal and actual character arguments
    found a mismatch and emitted a warning, it would skip further checks
    like that could lead to errors.  Fix that by continuing the checking.
    Also catch a NULL pointer dereference.

    gcc/fortran/ChangeLog:

            PR fortran/100274
            * interface.c (gfc_compare_actual_formal): Continue checks after
            emitting warning for argument length mismatch.
            * trans-expr.c (gfc_conv_procedure_call): Check for NULL pointer
            dereference.

    gcc/testsuite/ChangeLog:

            PR fortran/100274
            * gfortran.dg/argument_checking_25.f90: New test.

    (cherry picked from commit a8b79cc939d6786293f654c42a2d1b0ab040de0e)

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

* [Bug fortran/100274] [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
  2021-04-26 19:48 [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2021-05-05 19:40 ` cvs-commit at gcc dot gnu.org
@ 2021-05-05 19:55 ` cvs-commit at gcc dot gnu.org
  2021-05-05 19:59 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-05 19:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r9-9514-gd4a21a07125f73543ccc08fd96d4c41f37b6bd5d
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed May 5 15:25:50 2021 +0200

    PR fortran/100274 - ICE in gfc_conv_procedure_call, at
fortran/trans-expr.c:6131

    When the check for the length of formal and actual character arguments
    found a mismatch and emitted a warning, it would skip further checks
    like that could lead to errors.  Fix that by continuing the checking.
    Also catch a NULL pointer dereference.

    gcc/fortran/ChangeLog:

            PR fortran/100274
            * interface.c (gfc_compare_actual_formal): Continue checks after
            emitting warning for argument length mismatch.
            * trans-expr.c (gfc_conv_procedure_call): Check for NULL pointer
            dereference.

    gcc/testsuite/ChangeLog:

            PR fortran/100274
            * gfortran.dg/argument_checking_25.f90: New test.

    (cherry picked from commit a8b79cc939d6786293f654c42a2d1b0ab040de0e)

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

* [Bug fortran/100274] [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
  2021-04-26 19:48 [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2021-05-05 19:55 ` cvs-commit at gcc dot gnu.org
@ 2021-05-05 19:59 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-05-05 19:59 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #8 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-12, and backported to 11-, 10- and 9-branches.
Closing.

Thanks for the report!

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

end of thread, other threads:[~2021-05-05 19:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 19:48 [Bug fortran/100274] New: [9/10/11/12 Regression] ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131 gscfq@t-online.de
2021-04-26 21:00 ` [Bug fortran/100274] " anlauf at gcc dot gnu.org
2021-04-27 20:39 ` anlauf at gcc dot gnu.org
2021-04-27 20:57 ` anlauf at gcc dot gnu.org
2021-05-05 13:26 ` cvs-commit at gcc dot gnu.org
2021-05-05 19:00 ` cvs-commit at gcc dot gnu.org
2021-05-05 19:40 ` cvs-commit at gcc dot gnu.org
2021-05-05 19:55 ` cvs-commit at gcc dot gnu.org
2021-05-05 19:59 ` 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).