public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104572] New: ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646
@ 2022-02-16 17:34 gscfq@t-online.de
  2022-02-16 19:49 ` [Bug fortran/104572] " kargl at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gscfq@t-online.de @ 2022-02-16 17:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104572
           Summary: ICE in gfc_resolve_finalizers, at
                    fortran/resolve.cc:13646
           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 at least r5 :


$ cat z1.f90
module m
   type t
   contains
      final :: s
   end type
contains
   subroutine s(*)
   end
end


$ gfortran-12-20220213 -c z1.f90
f951: internal compiler error: Segmentation fault
0xcc8a9f crash_signal
        ../../gcc/toplev.cc:322
0x75abf3 gfc_resolve_finalizers
        ../../gcc/fortran/resolve.cc:13646
0x7726fd resolve_fl_derived
        ../../gcc/fortran/resolve.cc:15112
0x76c1f7 resolve_symbol
        ../../gcc/fortran/resolve.cc:15504
0x78b442 do_traverse_symtree
        ../../gcc/fortran/symbol.cc:4174
0x76f7a4 resolve_types
        ../../gcc/fortran/resolve.cc:17454
0x76ac3c gfc_resolve(gfc_namespace*)
        ../../gcc/fortran/resolve.cc:17569
0x752d72 gfc_parse_file()
        ../../gcc/fortran/parse.cc:6792
0x7a066f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.cc:216

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

* [Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646
  2022-02-16 17:34 [Bug fortran/104572] New: ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646 gscfq@t-online.de
@ 2022-02-16 19:49 ` kargl at gcc dot gnu.org
  2023-03-21 21:02 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-02-16 19:49 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-02-16
                 CC|                            |kargl at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from kargl at gcc dot gnu.org ---
Self explanatory.

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 835a4783718..1e7c3a07d0e 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -13643,6 +13653,13 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool
*finalizable)
        }
       arg = dummy_args->sym;

+      if (!arg)
+       {
+         gfc_error ("Argument of FINAL procedure at %L cannot be an "
+                    "alternate return", &list->proc_sym->declared_at);
+         goto error;
+       }
+
       /* This argument must be of our type.  */
       if (arg->ts.type != BT_DERIVED || arg->ts.u.derived != derived)
        {

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

* [Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646
  2022-02-16 17:34 [Bug fortran/104572] New: ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646 gscfq@t-online.de
  2022-02-16 19:49 ` [Bug fortran/104572] " kargl at gcc dot gnu.org
@ 2023-03-21 21:02 ` anlauf at gcc dot gnu.org
  2023-03-21 21:10 ` sgk at troutmask dot apl.washington.edu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-03-21 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #1)
> Self explanatory.
> 
> diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc

Yes.  Either this or:

@@ -13986,6 +13995,13 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool
*finalizable)
        }
       arg = dummy_args->sym;

+      if (!arg)
+       {
+         gfc_error ("Argument of FINAL procedure at %L must be of type %qs",
+                    &list->proc_sym->declared_at, derived->name);
+         goto error;
+       }
+
       if (arg->as && arg->as->type == AS_ASSUMED_RANK
          && ((list != derived->f2k_derived->finalizers) || list->next))
        {

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

* [Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646
  2022-02-16 17:34 [Bug fortran/104572] New: ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646 gscfq@t-online.de
  2022-02-16 19:49 ` [Bug fortran/104572] " kargl at gcc dot gnu.org
  2023-03-21 21:02 ` anlauf at gcc dot gnu.org
@ 2023-03-21 21:10 ` sgk at troutmask dot apl.washington.edu
  2023-03-22 18:25 ` cvs-commit at gcc dot gnu.org
  2023-03-22 19:11 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2023-03-21 21:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Mar 21, 2023 at 09:02:14PM +0000, anlauf at gcc dot gnu.org wrote:
> --- Comment #2 from anlauf at gcc dot gnu.org ---
> (In reply to kargl from comment #1)
> > Self explanatory.
> > 
> > diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
> 
> Yes.  Either this or:

I'm fine with gfortran emitting either error message.
As we've both put eyes on the bug, go ahead and use
your error message and commit.

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

* [Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646
  2022-02-16 17:34 [Bug fortran/104572] New: ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2023-03-21 21:10 ` sgk at troutmask dot apl.washington.edu
@ 2023-03-22 18:25 ` cvs-commit at gcc dot gnu.org
  2023-03-22 19:11 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-22 18:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:3e791f45ded89626bc1f9f8013728f6e035801b2

commit r13-6812-g3e791f45ded89626bc1f9f8013728f6e035801b2
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Mar 22 19:20:41 2023 +0100

    Fortran: improve checking of FINAL subroutine arguments [PR104572]

    gcc/fortran/ChangeLog:

            PR fortran/104572
            * resolve.cc (gfc_resolve_finalizers): Argument of a FINAL
subroutine
            cannot be an alternate return.

    gcc/testsuite/ChangeLog:

            PR fortran/104572
            * gfortran.dg/pr104572.f90: New test.

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

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

* [Bug fortran/104572] ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646
  2022-02-16 17:34 [Bug fortran/104572] New: ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2023-03-22 18:25 ` cvs-commit at gcc dot gnu.org
@ 2023-03-22 19:11 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-03-22 19:11 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #3)
> I'm fine with gfortran emitting either error message.
> As we've both put eyes on the bug, go ahead and use
> your error message and commit.

When using -std=f2018, the new testcase emits:

gcc/testsuite/gfortran.dg/pr104572.f90:12:17:

   12 |   subroutine s(*) ! { dg-error "Argument of FINAL procedure" }
      |                 1
Warning: Obsolescent feature: Alternate-return argument at (1)
gcc/testsuite/gfortran.dg/pr104572.f90:12:14:

   12 |   subroutine s(*) ! { dg-error "Argument of FINAL procedure" }
      |              1
Error: Argument of FINAL procedure at (1) must be of type 't'

The error message is also close to that emitted by other brands.

***

Closing.

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

end of thread, other threads:[~2023-03-22 19:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 17:34 [Bug fortran/104572] New: ICE in gfc_resolve_finalizers, at fortran/resolve.cc:13646 gscfq@t-online.de
2022-02-16 19:49 ` [Bug fortran/104572] " kargl at gcc dot gnu.org
2023-03-21 21:02 ` anlauf at gcc dot gnu.org
2023-03-21 21:10 ` sgk at troutmask dot apl.washington.edu
2023-03-22 18:25 ` cvs-commit at gcc dot gnu.org
2023-03-22 19:11 ` 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).