public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/107899] New: ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576
@ 2022-11-28 17:59 gscfq@t-online.de
  2022-11-28 20:56 ` [Bug fortran/107899] " anlauf at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gscfq@t-online.de @ 2022-11-28 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107899
           Summary: ICE in resolve_deallocate_expr, at
                    fortran/resolve.cc:7576
           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 :
(target instead of allocatable)


$ cat z1.f90
program p
   type t
   end type
   class(t), target :: x[:]
   if (allocated(x)) deallocate (x)
end


$ cat z2.f90
program p
   type t
   end type
   class(t), target :: x[:]
   deallocate(x)
end


$ gfortran-13-20221127 -c z1.f90 -fcoarray=lib
z1.f90:4:27:

    4 |    class(t), target :: x[:]
      |                           1
Error: Coarray variable 'x' at (1) shall not have codimensions with deferred
shape
z1.f90:5:17:

    5 |    if (allocated(x)) deallocate (x)
      |                 1
Error: 'array' argument of 'allocated' intrinsic at (1) must be ALLOCATABLE
f951: internal compiler error: Segmentation fault
0xf36d0f crash_signal
        ../../gcc/toplev.cc:314
0x87a956 resolve_deallocate_expr
        ../../gcc/fortran/resolve.cc:7576
0x87a956 resolve_allocate_deallocate
        ../../gcc/fortran/resolve.cc:8461
0x87cfac gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.cc:12291
0x87b2ff gfc_resolve_blocks(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.cc:10979
0x87b658 gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.cc:11971
0x87e407 resolve_codes
        ../../gcc/fortran/resolve.cc:17628
0x87e4ce gfc_resolve(gfc_namespace*)
        ../../gcc/fortran/resolve.cc:17663
0x866294 resolve_all_program_units
        ../../gcc/fortran/parse.cc:6631
0x866294 gfc_parse_file()
        ../../gcc/fortran/parse.cc:6887
0x8b4d3f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.cc:229

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

* [Bug fortran/107899] ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576
  2022-11-28 17:59 [Bug fortran/107899] New: ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576 gscfq@t-online.de
@ 2022-11-28 20:56 ` anlauf at gcc dot gnu.org
  2022-12-03 18:28 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-11-28 20:56 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org
   Last reconfirmed|                            |2022-11-28
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

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

Tentative patch for NULL pointer dereference:

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 3396c6ce4a7..ea67de7c07a 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -7570,7 +7573,7 @@ resolve_deallocate_expr (gfc_expr *e)
   sym = e->symtree->n.sym;
   unlimited = UNLIMITED_POLY(sym);

-  if (sym->ts.type == BT_CLASS)
+  if (sym->ts.type == BT_CLASS && sym->attr.class_ok)
     {
       allocatable = CLASS_DATA (sym)->attr.allocatable;
       pointer = CLASS_DATA (sym)->attr.class_pointer;

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

* [Bug fortran/107899] ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576
  2022-11-28 17:59 [Bug fortran/107899] New: ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576 gscfq@t-online.de
  2022-11-28 20:56 ` [Bug fortran/107899] " anlauf at gcc dot gnu.org
@ 2022-12-03 18:28 ` anlauf at gcc dot gnu.org
  2022-12-04 19:34 ` cvs-commit at gcc dot gnu.org
  2022-12-04 19:44 ` anlauf at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-03 18:28 UTC (permalink / raw)
  To: gcc-bugs

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

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 #2 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-December/058566.html

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

* [Bug fortran/107899] ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576
  2022-11-28 17:59 [Bug fortran/107899] New: ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576 gscfq@t-online.de
  2022-11-28 20:56 ` [Bug fortran/107899] " anlauf at gcc dot gnu.org
  2022-12-03 18:28 ` anlauf at gcc dot gnu.org
@ 2022-12-04 19:34 ` cvs-commit at gcc dot gnu.org
  2022-12-04 19:44 ` anlauf at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-04 19:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:9123863828b2f86e7a6aafba38738e7204ed19ca

commit r13-4484-g9123863828b2f86e7a6aafba38738e7204ed19ca
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Dec 3 19:21:07 2022 +0100

    Fortran: error recovery handling invalid CLASS variable [PR107899]

    gcc/fortran/ChangeLog:

            PR fortran/107899
            * resolve.cc (resolve_deallocate_expr): Avoid NULL pointer
dereference
            on invalid CLASS variable.

    gcc/testsuite/ChangeLog:

            PR fortran/107899
            * gfortran.dg/pr107899.f90: New test.

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

* [Bug fortran/107899] ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576
  2022-11-28 17:59 [Bug fortran/107899] New: ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-12-04 19:34 ` cvs-commit at gcc dot gnu.org
@ 2022-12-04 19:44 ` anlauf at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-04 19:44 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

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

Thanks for the report!

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

end of thread, other threads:[~2022-12-04 19:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-28 17:59 [Bug fortran/107899] New: ICE in resolve_deallocate_expr, at fortran/resolve.cc:7576 gscfq@t-online.de
2022-11-28 20:56 ` [Bug fortran/107899] " anlauf at gcc dot gnu.org
2022-12-03 18:28 ` anlauf at gcc dot gnu.org
2022-12-04 19:34 ` cvs-commit at gcc dot gnu.org
2022-12-04 19:44 ` 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).