public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104351] New: ICE in gfc_generate_initializer, at fortran/expr.cc:5140
@ 2022-02-02 18:45 gscfq@t-online.de
  2022-02-02 18:45 ` [Bug fortran/104351] " gscfq@t-online.de
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gscfq@t-online.de @ 2022-02-02 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104351
           Summary: ICE in gfc_generate_initializer, at
                    fortran/expr.cc:5140
           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 :
(name conflict)


$ cat z1.f90
program p
   implicit none
   type t
   end type
   type(t) :: f
contains
   real function f() result(z)
      z = 0.0
   end
end


$ gfortran-12-20220130 -c z1.f90
z1.f90:9:6:

    9 |    end
      |      1
internal compiler error: Segmentation fault
0xcc655f crash_signal
        ../../gcc/toplev.cc:322
0x6f484a gfc_generate_initializer(gfc_typespec*, bool)
        ../../gcc/fortran/expr.cc:5140
0x7d05b7 gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.cc:7709
0x7cefcc gfc_generate_contained_functions
        ../../gcc/fortran/trans-decl.cc:5777
0x7cefcc gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.cc:7586
0x751efe translate_all_program_units
        ../../gcc/fortran/parse.cc:6651
0x751efe gfc_parse_file()
        ../../gcc/fortran/parse.cc:6938
0x79eecf gfc_be_parse_file
        ../../gcc/fortran/f95-lang.cc:216

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

* [Bug fortran/104351] ICE in gfc_generate_initializer, at fortran/expr.cc:5140
  2022-02-02 18:45 [Bug fortran/104351] New: ICE in gfc_generate_initializer, at fortran/expr.cc:5140 gscfq@t-online.de
@ 2022-02-02 18:45 ` gscfq@t-online.de
  2023-10-10 21:02 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: gscfq@t-online.de @ 2022-02-02 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

G. Steinmetz <gscfq@t-online.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code

--- Comment #1 from G. Steinmetz <gscfq@t-online.de> ---

Without a result-name :


$ cat z2.f90
program p
   implicit none
   type t
   end type
   type(t) :: f
contains
   real function f()
      f = 0.0
   end
end


$ gfortran-12-20220130 -c z2.f90
z2.f90:7:20:

    7 |    real function f()
      |                    1
Error: Symbol 'f' at (1) already has basic type of DERIVED
z2.f90:8:8:

    8 |       f = 0.0
      |        1
Error: Symbol 'f' at (1) has already been host associated
z2.f90:1:9:

    1 | program p
      |         1
......
   10 | end
      |   2
Error: Two main PROGRAMs at (1) and (2)

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

* [Bug fortran/104351] ICE in gfc_generate_initializer, at fortran/expr.cc:5140
  2022-02-02 18:45 [Bug fortran/104351] New: ICE in gfc_generate_initializer, at fortran/expr.cc:5140 gscfq@t-online.de
  2022-02-02 18:45 ` [Bug fortran/104351] " gscfq@t-online.de
@ 2023-10-10 21:02 ` anlauf at gcc dot gnu.org
  2023-10-11 19:41 ` 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-10-10 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |anlauf at gcc dot gnu.org
   Last reconfirmed|                            |2023-10-10
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from anlauf at gcc dot gnu.org ---
The following untested, semi-obvious patch fixes the ICE:

diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 4a3c5b86de0..892e3788b9d 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -1404,7 +1421,9 @@ get_proc_name (const char *name, gfc_symbol **result,
bool module_fcn_entry)
       /* Trap declarations of attributes in encompassing scope.  The
         signature for this is that ts.kind is nonzero for no-CLASS
         entity.  For a CLASS entity, ts.kind is zero.  */
-      if ((sym->ts.kind != 0 || sym->ts.type == BT_CLASS)
+      if ((sym->ts.kind != 0
+          || sym->ts.type == BT_CLASS
+          || sym->ts.type == BT_DERIVED)
          && !sym->attr.implicit_type
          && sym->attr.proc == 0
          && gfc_current_ns->parent != NULL
@@ -7622,6 +7641,10 @@ gfc_match_function_decl (void)
           if (current_ts.type != BT_UNKNOWN
              && !gfc_add_type (result, &current_ts, &gfc_current_locus))
            goto cleanup;
+         if (current_ts.type != BT_UNKNOWN
+             && sym->ts.type != BT_UNKNOWN
+             && sym->ts.type != current_ts.type)
+           goto cleanup;
          sym->result = result;
        }

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

* [Bug fortran/104351] ICE in gfc_generate_initializer, at fortran/expr.cc:5140
  2022-02-02 18:45 [Bug fortran/104351] New: ICE in gfc_generate_initializer, at fortran/expr.cc:5140 gscfq@t-online.de
  2022-02-02 18:45 ` [Bug fortran/104351] " gscfq@t-online.de
  2023-10-10 21:02 ` anlauf at gcc dot gnu.org
@ 2023-10-11 19:41 ` anlauf at gcc dot gnu.org
  2023-10-13 20:08 ` cvs-commit at gcc dot gnu.org
  2023-10-14 20:02 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-11 19:41 UTC (permalink / raw)
  To: gcc-bugs

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

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-October/059812.html

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

* [Bug fortran/104351] ICE in gfc_generate_initializer, at fortran/expr.cc:5140
  2022-02-02 18:45 [Bug fortran/104351] New: ICE in gfc_generate_initializer, at fortran/expr.cc:5140 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2023-10-11 19:41 ` anlauf at gcc dot gnu.org
@ 2023-10-13 20:08 ` cvs-commit at gcc dot gnu.org
  2023-10-14 20:02 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-13 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

commit r14-4632-gd78fef5371759849944966dec65d9e987efba509
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Oct 11 21:29:35 2023 +0200

    Fortran: name conflict between internal procedure and derived type
[PR104351]

    gcc/fortran/ChangeLog:

            PR fortran/104351
            * decl.cc (get_proc_name): Extend name conflict detection between
            internal procedure and previous declaration also to derived type.

    gcc/testsuite/ChangeLog:

            PR fortran/104351
            * gfortran.dg/derived_function_interface_1.f90: Adjust pattern.
            * gfortran.dg/pr104351.f90: New test.

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

* [Bug fortran/104351] ICE in gfc_generate_initializer, at fortran/expr.cc:5140
  2022-02-02 18:45 [Bug fortran/104351] New: ICE in gfc_generate_initializer, at fortran/expr.cc:5140 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2023-10-13 20:08 ` cvs-commit at gcc dot gnu.org
@ 2023-10-14 20:02 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-10-14 20:02 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

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

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

end of thread, other threads:[~2023-10-14 20:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02 18:45 [Bug fortran/104351] New: ICE in gfc_generate_initializer, at fortran/expr.cc:5140 gscfq@t-online.de
2022-02-02 18:45 ` [Bug fortran/104351] " gscfq@t-online.de
2023-10-10 21:02 ` anlauf at gcc dot gnu.org
2023-10-11 19:41 ` anlauf at gcc dot gnu.org
2023-10-13 20:08 ` cvs-commit at gcc dot gnu.org
2023-10-14 20:02 ` 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).