public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/108544] New: ICE in check_host_association, at fortran/resolve.cc:6135
@ 2023-01-25 17:49 gscfq@t-online.de
  2023-01-25 20:14 ` [Bug fortran/108544] " anlauf at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gscfq@t-online.de @ 2023-01-25 17:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108544
           Summary: ICE in check_host_association, at
                    fortran/resolve.cc:6135
           Product: gcc
           Version: 13.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
   implicit none
contains
   subroutine s
      select type (s => 1)
      end select
   end
end


$ cat z3.f90
module m
contains
   subroutine s
      select type (s => null())
      end select
   end
end


$ cat z4.f90
module m
   type t
   end type
   type(t) :: x
contains
   subroutine s
      select type (s => x)
      end select
   end
end


$ gfortran-13-20230122 -c z1.f90
f951: internal compiler error: Segmentation fault
0xdaa49f crash_signal
        ../../gcc/toplev.cc:314
0x838506 check_host_association
        ../../gcc/fortran/resolve.cc:6135
0x838506 gfc_resolve_expr(gfc_expr*)
        ../../gcc/fortran/resolve.cc:7194
0x83fa6c gfc_resolve_expr(gfc_expr*)
        ../../gcc/fortran/resolve.cc:7162
0x83fa6c gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.cc:11982
0x8416a7 resolve_codes
        ../../gcc/fortran/resolve.cc:17629
0x8415de resolve_codes
        ../../gcc/fortran/resolve.cc:17612
0x84176e gfc_resolve(gfc_namespace*)
        ../../gcc/fortran/resolve.cc:17664
0x8292d2 gfc_parse_file()
        ../../gcc/fortran/parse.cc:6862
0x8774bf gfc_be_parse_file
        ../../gcc/fortran/f95-lang.cc:229

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

* [Bug fortran/108544] ICE in check_host_association, at fortran/resolve.cc:6135
  2023-01-25 17:49 [Bug fortran/108544] New: ICE in check_host_association, at fortran/resolve.cc:6135 gscfq@t-online.de
@ 2023-01-25 20:14 ` anlauf at gcc dot gnu.org
  2023-01-25 21:41 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-01-25 20:14 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-01-25
             Status|UNCONFIRMED                 |NEW

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

The following patch avoids a NULL pointer dereference:

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 94213cd3cd4..c6f12bfecdb 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -6132,6 +6138,9 @@ check_host_association (gfc_expr *e)
                  return false;
                }

+             if (ref == NULL)
+               return false;
+
              gcc_assert (ref->type == REF_ARRAY);

              /* Grab the start expressions from the array ref and

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

* [Bug fortran/108544] ICE in check_host_association, at fortran/resolve.cc:6135
  2023-01-25 17:49 [Bug fortran/108544] New: ICE in check_host_association, at fortran/resolve.cc:6135 gscfq@t-online.de
  2023-01-25 20:14 ` [Bug fortran/108544] " anlauf at gcc dot gnu.org
@ 2023-01-25 21:41 ` anlauf at gcc dot gnu.org
  2023-01-25 22:00 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-01-25 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
I played a little and found a variation of testcase pr96102.f90
that was silently accepted but is rejected by Intel, NAG, Cray, NVidia:

module m
  type mytype
    integer :: i
  end type
  type(mytype) :: d = mytype (42) ! { dg-error "is host associated" }
  integer      :: n = 2           ! { dg-error "is host associated" }
contains
  subroutine s
    if ( n   /= 0 ) stop 1  ! { dg-error "internal procedure of the same name"
}
    if ( d%i /= 0 ) stop 2  ! { dg-error "internal procedure of the same name"
}
  contains
    subroutine n()
    end
    subroutine d()
    end
  end
end

This need removing just one line of code in addition to comment#1:

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 94213cd3cd4..b40e04513b5 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -6087,7 +6093,6 @@ check_host_association (gfc_expr *e)
       gfc_find_symbol (e->symtree->name, gfc_current_ns, 1, &sym);

       if (sym && old_sym != sym
-             && sym->ts.type == old_sym->ts.type
              && sym->attr.flavor == FL_PROCEDURE
              && sym->attr.contained)
        {
@@ -6132,6 +6137,9 @@ check_host_association (gfc_expr *e)
                  return false;
                }

+             if (ref == NULL)
+               return false;
+
              gcc_assert (ref->type == REF_ARRAY);

              /* Grab the start expressions from the array ref and

Am I missing something?

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

* [Bug fortran/108544] ICE in check_host_association, at fortran/resolve.cc:6135
  2023-01-25 17:49 [Bug fortran/108544] New: ICE in check_host_association, at fortran/resolve.cc:6135 gscfq@t-online.de
  2023-01-25 20:14 ` [Bug fortran/108544] " anlauf at gcc dot gnu.org
  2023-01-25 21:41 ` anlauf at gcc dot gnu.org
@ 2023-01-25 22:00 ` anlauf at gcc dot gnu.org
  2023-01-26 18:35 ` cvs-commit at gcc dot gnu.org
  2023-01-26 19:11 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-01-25 22:00 UTC (permalink / raw)
  To: gcc-bugs

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

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 ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2023-January/058835.html

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

* [Bug fortran/108544] ICE in check_host_association, at fortran/resolve.cc:6135
  2023-01-25 17:49 [Bug fortran/108544] New: ICE in check_host_association, at fortran/resolve.cc:6135 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2023-01-25 22:00 ` anlauf at gcc dot gnu.org
@ 2023-01-26 18:35 ` cvs-commit at gcc dot gnu.org
  2023-01-26 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-01-26 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

commit r13-5400-gc8e07c7951421e718bcafbe5924e75c9aa133af9
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Jan 25 22:47:26 2023 +0100

    Fortran: fix ICE in check_host_association [PR108544]

    gcc/fortran/ChangeLog:

            PR fortran/108544
            * resolve.cc (check_host_association): Extend host association
check
            so that it is not restricted to functions.  Also prevent NULL
pointer
            dereference.

    gcc/testsuite/ChangeLog:

            PR fortran/108544
            * gfortran.dg/pr108544.f90: New test.
            * gfortran.dg/pr96102b.f90: New test.

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

* [Bug fortran/108544] ICE in check_host_association, at fortran/resolve.cc:6135
  2023-01-25 17:49 [Bug fortran/108544] New: ICE in check_host_association, at fortran/resolve.cc:6135 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2023-01-26 18:35 ` cvs-commit at gcc dot gnu.org
@ 2023-01-26 19:11 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-01-26 19:11 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-13.  Closing.

Thanks for the report!

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25 17:49 [Bug fortran/108544] New: ICE in check_host_association, at fortran/resolve.cc:6135 gscfq@t-online.de
2023-01-25 20:14 ` [Bug fortran/108544] " anlauf at gcc dot gnu.org
2023-01-25 21:41 ` anlauf at gcc dot gnu.org
2023-01-25 22:00 ` anlauf at gcc dot gnu.org
2023-01-26 18:35 ` cvs-commit at gcc dot gnu.org
2023-01-26 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).