public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733
@ 2022-02-22 19:34 gscfq@t-online.de
  2022-02-24 15:31 ` [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767 marxin at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2022-02-22 19:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104649
           Summary: ICE in gfc_match_formal_arglist, at
                    fortran/decl.cc:6733
           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: ---

Affects versions down to r6 :


$ cat z1.f90
module m
   interface
      module subroutine s(x)
         real :: x
      end
   end interface
end
submodule(m) m2
contains
   module subroutine s(*)
   end
end


$ cat z2.f90
module m
   interface
      module subroutine s(*)
      end
   end interface
end
submodule(m) m2
contains
   module subroutine s(x)
      real :: x
   end
end


$ gfortran-12-20220220 -c z1.f90
f951: internal compiler error: Segmentation fault
0xcc909f crash_signal
        ../../gcc/toplev.cc:322
0x6d9f81 gfc_match_formal_arglist(gfc_symbol*, int, int, bool)
        ../../gcc/fortran/decl.cc:6733
0x6dfaaf gfc_match_subroutine()
        ../../gcc/fortran/decl.cc:7957
0x74bb57 decode_statement
        ../../gcc/fortran/parse.cc:384
0x74d54a next_free
        ../../gcc/fortran/parse.cc:1397
0x74d54a next_statement
        ../../gcc/fortran/parse.cc:1629
0x751f8c parse_contained
        ../../gcc/fortran/parse.cc:6039
0x752e17 parse_module
        ../../gcc/fortran/parse.cc:6466
0x753147 gfc_parse_file()
        ../../gcc/fortran/parse.cc:6773
0x7a0a5f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.cc:216

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

* [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767
  2022-02-22 19:34 [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 gscfq@t-online.de
@ 2022-02-24 15:31 ` marxin at gcc dot gnu.org
  2022-05-17 17:44 ` kargl at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-02-24 15:31 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE in                      |ICE in
                   |gfc_match_formal_arglist,   |gfc_match_formal_arglist,
                   |at fortran/decl.cc:6733     |at fortran/decl.cc:6733
                   |                            |since
                   |                            |r6-1958-g4668d6f9c00d4767
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |pault at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-02-24

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r6-1958-g4668d6f9c00d4767.

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

* [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767
  2022-02-22 19:34 [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 gscfq@t-online.de
  2022-02-24 15:31 ` [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767 marxin at gcc dot gnu.org
@ 2022-05-17 17:44 ` kargl at gcc dot gnu.org
  2023-07-09 17:59 ` pault at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-05-17 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org
           Priority|P3                          |P4

--- Comment #2 from kargl at gcc dot gnu.org ---
Null pointer dereference.


diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index bd586e75008..8e2cd511c4d 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -6730,12 +6730,20 @@ ok:
              || (p->next == NULL && q->next != NULL))
            arg_count_mismatch = true;
          else if ((p->sym == NULL && q->sym == NULL)
-                   || strcmp (p->sym->name, q->sym->name) == 0)
+                   || (p->sym && q->sym
+                       && strcmp (p->sym->name, q->sym->name) == 0))
            continue;
          else
-           gfc_error_now ("Mismatch in MODULE PROCEDURE formal "
-                          "argument names (%s/%s) at %C",
-                          p->sym->name, q->sym->name);
+           {
+             if (q->sym)
+               gfc_error_now ("Mismatch in MODULE PROCEDURE formal "
+                               "argument names (%qs/%qs) at %C",
+                               p->sym->name, q->sym->name);
+             else
+               gfc_error_now ("Mismatch in MODULE PROCEDURE formal argument "
+                               "name, %qs, and alternate return at %C",
+                               p->sym->name);
+           }
        }

       if (arg_count_mismatch)

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

* [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767
  2022-02-22 19:34 [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 gscfq@t-online.de
  2022-02-24 15:31 ` [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767 marxin at gcc dot gnu.org
  2022-05-17 17:44 ` kargl at gcc dot gnu.org
@ 2023-07-09 17:59 ` pault at gcc dot gnu.org
  2023-10-24 20:16 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu.org @ 2023-07-09 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to kargl from comment #2)
> Null pointer dereference.
> 
> 
> diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
> index bd586e75008..8e2cd511c4d 100644
> --- a/gcc/fortran/decl.cc
> +++ b/gcc/fortran/decl.cc
> @@ -6730,12 +6730,20 @@ ok:
>  	      || (p->next == NULL && q->next != NULL))
>  	    arg_count_mismatch = true;
>  	  else if ((p->sym == NULL && q->sym == NULL)
> -		    || strcmp (p->sym->name, q->sym->name) == 0)
> +		    || (p->sym && q->sym
> +			&& strcmp (p->sym->name, q->sym->name) == 0))
>  	    continue;
>  	  else
> -	    gfc_error_now ("Mismatch in MODULE PROCEDURE formal "
> -			   "argument names (%s/%s) at %C",
> -			   p->sym->name, q->sym->name);
> +	    {
> +	      if (q->sym)
> +		gfc_error_now ("Mismatch in MODULE PROCEDURE formal "
> +				"argument names (%qs/%qs) at %C",
> +				p->sym->name, q->sym->name);
> +	      else
> +		gfc_error_now ("Mismatch in MODULE PROCEDURE formal argument "
> +				"name, %qs, and alternate return at %C",
> +				p->sym->name);
> +	    }
>  	}
>  
>        if (arg_count_mismatch)

The second testcase still segfaults and everything is so optimised away that I
cannot figure out why.

Paul

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

* [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767
  2022-02-22 19:34 [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2023-07-09 17:59 ` pault at gcc dot gnu.org
@ 2023-10-24 20:16 ` anlauf at gcc dot gnu.org
  2023-10-26 20:44 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-24 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #4 from anlauf at gcc dot gnu.org ---
Created attachment 56194
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56194&action=edit
Extension of Steve's patch

The logic needs to take care of 3 situations instead of only 2.
Steve's patch was almost technically correct...

Not sure if the error messages need more tweaking.

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

* [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767
  2022-02-22 19:34 [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2023-10-24 20:16 ` anlauf at gcc dot gnu.org
@ 2023-10-26 20:44 ` anlauf at gcc dot gnu.org
  2023-10-27 17:18 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-26 20:44 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2023-October/059872.html

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

* [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767
  2022-02-22 19:34 [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2023-10-26 20:44 ` anlauf at gcc dot gnu.org
@ 2023-10-27 17:18 ` cvs-commit at gcc dot gnu.org
  2023-10-27 17:50 ` sgk at troutmask dot apl.washington.edu
  2023-10-27 18:51 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-27 17:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

commit r14-4983-gc6430d3e6d3279c7e4be9d189031a17bb3dec347
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Oct 26 22:32:35 2023 +0200

    Fortran: diagnostics of MODULE PROCEDURE declaration conflicts [PR104649]

    gcc/fortran/ChangeLog:

            PR fortran/104649
            * decl.cc (gfc_match_formal_arglist): Handle conflicting
declarations
            of a MODULE PROCEDURE when one of the declarations is an alternate
            return.

    gcc/testsuite/ChangeLog:

            PR fortran/104649
            * gfortran.dg/pr104649.f90: New test.

    Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>

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

* [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767
  2022-02-22 19:34 [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2023-10-27 17:18 ` cvs-commit at gcc dot gnu.org
@ 2023-10-27 17:50 ` sgk at troutmask dot apl.washington.edu
  2023-10-27 18:51 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2023-10-27 17:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Fri, Oct 27, 2023 at 05:18:02PM +0000, cvs-commit at gcc dot gnu.org wrote:
> 
> 
> commit r14-4983-gc6430d3e6d3279c7e4be9d189031a17bb3dec347
> Author: Harald Anlauf <anlauf@gmx.de>
> Date:   Thu Oct 26 22:32:35 2023 +0200
> 

Thanks for taking care of this issue.  Sorry about missing
the second case, and good catch.

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

* [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767
  2022-02-22 19:34 [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2023-10-27 17:50 ` sgk at troutmask dot apl.washington.edu
@ 2023-10-27 18:51 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-27 18:51 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #8 from anlauf at gcc dot gnu.org ---
Fixed in gcc-14.  Closing.

Thanks for the report!

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

end of thread, other threads:[~2023-10-27 18:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 19:34 [Bug fortran/104649] New: ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 gscfq@t-online.de
2022-02-24 15:31 ` [Bug fortran/104649] ICE in gfc_match_formal_arglist, at fortran/decl.cc:6733 since r6-1958-g4668d6f9c00d4767 marxin at gcc dot gnu.org
2022-05-17 17:44 ` kargl at gcc dot gnu.org
2023-07-09 17:59 ` pault at gcc dot gnu.org
2023-10-24 20:16 ` anlauf at gcc dot gnu.org
2023-10-26 20:44 ` anlauf at gcc dot gnu.org
2023-10-27 17:18 ` cvs-commit at gcc dot gnu.org
2023-10-27 17:50 ` sgk at troutmask dot apl.washington.edu
2023-10-27 18:51 ` 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).