public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/107423] New: ICE in parse_spec, at fortran/parse.cc:4017
@ 2022-10-26 18:35 gscfq@t-online.de
  2022-10-27  0:10 ` [Bug fortran/107423] " kargl at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gscfq@t-online.de @ 2022-10-26 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107423
           Summary: ICE in parse_spec, at fortran/parse.cc:4017
           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 r8 with option -std=f95
and file gfortran.dg/pdt_12.f03 or this reduction :


$ cat z1.f90
program p
   type t(k)
      integer, kind :: k
      integer :: a
   end type
contains
   function f()
      type(t(4)), allocatable :: x
      allocate (t(4) :: x)
   end
end


$ gfortran-13-20221023 -c z1.f90
$
$ gfortran-13-20221023 -c z1.f90 -std=f95
z1.f90:3:23:

    3 |       integer, kind :: k
      |                       1
Error: Fortran 2003: KIND attribute at (1) in a TYPE definition
z1.f90:8:15:

    8 |       type(t(4)), allocatable :: x
      |               1
Error: Invalid character in name at (1)
z1.f90:9:18:

    9 |       allocate (t(4) :: x)
      |                  1
Error: Derived type 't' cannot be used as a variable at (1)
z1.f90:10:6:

   10 |    end
      |      1
Error: Fortran 2008: END statement instead of END FUNCTION statement at (1)
z1.f90:11:3:

   11 | end
      |   1
Error: Fortran 2008: END statement instead of END FUNCTION statement at (1)
f951: internal compiler error: Segmentation fault
0xf43b3f crash_signal
        ../../gcc/toplev.cc:314
0x85c4de parse_spec
        ../../gcc/fortran/parse.cc:4017
0x85ea5c parse_progunit
        ../../gcc/fortran/parse.cc:6237
0x85ee41 parse_contained
        ../../gcc/fortran/parse.cc:6138
0x85ece6 parse_progunit
        ../../gcc/fortran/parse.cc:6309
0x860121 gfc_parse_file()
        ../../gcc/fortran/parse.cc:6782
0x8aec0f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.cc:229

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

* [Bug fortran/107423] ICE in parse_spec, at fortran/parse.cc:4017
  2022-10-26 18:35 [Bug fortran/107423] New: ICE in parse_spec, at fortran/parse.cc:4017 gscfq@t-online.de
@ 2022-10-27  0:10 ` kargl at gcc dot gnu.org
  2022-12-13 18:09 ` cvs-commit at gcc dot gnu.org
  2022-12-13 21:16 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-10-27  0:10 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-10-27
             Status|UNCONFIRMED                 |NEW
           Priority|P3                          |P4
     Ever confirmed|0                           |1
           Keywords|ice-on-valid-code           |ice-on-invalid-code
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
It is actually an ICE on invalid code as type-params were added in F2008 or
F2018.  This is an ICE caused by run-on errors where a NULL pointer is
dereferenced.  Fixed by

diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index 5b13441912a..25b987c7bef 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -3994,7 +3994,7 @@ parse_spec (gfc_statement st)
       gfc_symbol* proc = gfc_current_ns->proc_name;
       gcc_assert (proc);

-      if (proc->result->ts.type == BT_UNKNOWN)
+      if (proc->result && proc->result->ts.type == BT_UNKNOWN)
        function_result_typed = true;
     }

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

* [Bug fortran/107423] ICE in parse_spec, at fortran/parse.cc:4017
  2022-10-26 18:35 [Bug fortran/107423] New: ICE in parse_spec, at fortran/parse.cc:4017 gscfq@t-online.de
  2022-10-27  0:10 ` [Bug fortran/107423] " kargl at gcc dot gnu.org
@ 2022-12-13 18:09 ` cvs-commit at gcc dot gnu.org
  2022-12-13 21:16 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-13 18:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:531ca06c007d4c4d156637083dcad7f25ac8713d

commit r13-4681-g531ca06c007d4c4d156637083dcad7f25ac8713d
Author: Steve Kargl <kargl@gcc.gnu.org>
Date:   Mon Dec 12 21:11:07 2022 +0100

    Fortran: NULL pointer dereference while parsing a function [PR107423]

    gcc/fortran/ChangeLog:

            PR fortran/107423
            * parse.cc (parse_spec): Avoid NULL pointer dereference when
parsing
            a function and an error occured.

    gcc/testsuite/ChangeLog:

            PR fortran/107423
            * gfortran.dg/pr107423.f90: New test.

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

* [Bug fortran/107423] ICE in parse_spec, at fortran/parse.cc:4017
  2022-10-26 18:35 [Bug fortran/107423] New: ICE in parse_spec, at fortran/parse.cc:4017 gscfq@t-online.de
  2022-10-27  0:10 ` [Bug fortran/107423] " kargl at gcc dot gnu.org
  2022-12-13 18:09 ` cvs-commit at gcc dot gnu.org
@ 2022-12-13 21:16 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-13 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |13.0
         Resolution|---                         |FIXED

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

Thanks for the report!

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

end of thread, other threads:[~2022-12-13 21:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 18:35 [Bug fortran/107423] New: ICE in parse_spec, at fortran/parse.cc:4017 gscfq@t-online.de
2022-10-27  0:10 ` [Bug fortran/107423] " kargl at gcc dot gnu.org
2022-12-13 18:09 ` cvs-commit at gcc dot gnu.org
2022-12-13 21:16 ` 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).