public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/114535] New: ICE with elemental finalizer
@ 2024-03-31  6:59 abensonca at gcc dot gnu.org
  2024-03-31 11:43 ` [Bug fortran/114535] " pault at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: abensonca at gcc dot gnu.org @ 2024-03-31  6:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114535
           Summary: ICE with elemental finalizer
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: abensonca at gcc dot gnu.org
  Target Milestone: ---

The following code (which must be in two files to trigger the error) causes an
ICE using the latest gfortran.

$ cat ice1.F90
module iv
  type, public :: vs
   contains
     final :: destructor
  end type vs
contains
 elemental subroutine destructor(s)
    type(vs), intent(inout) :: s
  end subroutine destructor
end module iv

$ cat ice2.F90                                                     module d
contains
  function en() result(dd)
    use :: iv
    type(vs) :: dd
    return
  end function en
end module d

module ni
contains
  subroutine iss()
    use :: d
    return
  end subroutine iss
end module ni

$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/data001/abenson/Galacticus/Tools_Devel/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-git/configure
--prefix=/home/abenson/Galacticus/Tools_Devel --enable-languages=c,c++,fortran
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240330 (experimental) (GCC)

$ gfortran -c ice1.F90 -o ice1.o   
$ gfortran -c ice2.F90 -o ice2.o                                  
ice2.F90:16:13:                                         
   16 | end module ni                                         |             1
internal compiler error: in gfc_trans_call, at fortran/trans-stmt.cc:400       
                                0x78ddb6 gfc_trans_call(gfc_code*, bool,
tree_node*, tree_node*, bool)
        ../../gcc-git/gcc/fortran/trans-stmt.cc:400     0xaa8a1b trans_code    
                                        ../../gcc-git/gcc/fortran/trans.cc:2431
0xb47c14 gfc_trans_simple_do
        ../../gcc-git/gcc/fortran/trans-stmt.cc:2521
0xb47c14 gfc_trans_do(gfc_code*, tree_node*)
        ../../gcc-git/gcc/fortran/trans-stmt.cc:2653
0xaa898a trans_code                                            
../../gcc-git/gcc/fortran/trans.cc:2463
0xb485e9 gfc_trans_integer_select                              
../../gcc-git/gcc/fortran/trans-stmt.cc:3199
0xb485e9 gfc_trans_select(gfc_code*)
        ../../gcc-git/gcc/fortran/trans-stmt.cc:3692
0xaa8957 trans_code
        ../../gcc-git/gcc/fortran/trans.cc:2475
0xadd6fb gfc_generate_function_code(gfc_namespace*)
        ../../gcc-git/gcc/fortran/trans-decl.cc:7879
0xaadbf1 gfc_generate_module_code(gfc_namespace*)
        ../../gcc-git/gcc/fortran/trans.cc:2785
0xa5113d translate_all_program_units
        ../../gcc-git/gcc/fortran/parse.cc:7086
0xa5113d gfc_parse_file()
        ../../gcc-git/gcc/fortran/parse.cc:7413
0xaa546f gfc_be_parse_file
        ../../gcc-git/gcc/fortran/f95-lang.cc:241
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

This only occurs if the FINAL subroutine is ELEMENTAL.

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

* [Bug fortran/114535] ICE with elemental finalizer
  2024-03-31  6:59 [Bug fortran/114535] New: ICE with elemental finalizer abensonca at gcc dot gnu.org
@ 2024-03-31 11:43 ` pault at gcc dot gnu.org
  2024-03-31 11:50 ` [Bug fortran/114535] [13/14 regression] " pault at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu.org @ 2024-03-31 11:43 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-03-31

--- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> ---
Hi Andrew,

Confirmed.

A work around is:

module ni
  implicit none
contains
  subroutine iss()
    use :: iv      ! Implies something is awry in module.cc
    use :: d
    return
  end subroutine iss
end module ni

Thanks for the report. I'll take it but it has been a while since I looked at
module.cc.

Regards

Paul

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

* [Bug fortran/114535] [13/14 regression] ICE with elemental finalizer
  2024-03-31  6:59 [Bug fortran/114535] New: ICE with elemental finalizer abensonca at gcc dot gnu.org
  2024-03-31 11:43 ` [Bug fortran/114535] " pault at gcc dot gnu.org
@ 2024-03-31 11:50 ` pault at gcc dot gnu.org
  2024-03-31 16:33 ` abensonca at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu.org @ 2024-03-31 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE with elemental          |[13/14 regression] ICE with
                   |finalizer                   |elemental finalizer

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
It seems to be OK with 12-branch.

It's not unlike some of the problems with your smart pointer work.

I have a couple more regressions to take care of and the, I promise, I will
turn to this one.

Paul

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

* [Bug fortran/114535] [13/14 regression] ICE with elemental finalizer
  2024-03-31  6:59 [Bug fortran/114535] New: ICE with elemental finalizer abensonca at gcc dot gnu.org
  2024-03-31 11:43 ` [Bug fortran/114535] " pault at gcc dot gnu.org
  2024-03-31 11:50 ` [Bug fortran/114535] [13/14 regression] " pault at gcc dot gnu.org
@ 2024-03-31 16:33 ` abensonca at gcc dot gnu.org
  2024-04-01 11:38 ` pault at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: abensonca at gcc dot gnu.org @ 2024-03-31 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Benson <abensonca at gcc dot gnu.org> ---
Thanks Paul. The workaround is very helpful and lets me continue making
progress in the rest of my work for now. Thanks again!

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

* [Bug fortran/114535] [13/14 regression] ICE with elemental finalizer
  2024-03-31  6:59 [Bug fortran/114535] New: ICE with elemental finalizer abensonca at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-03-31 16:33 ` abensonca at gcc dot gnu.org
@ 2024-04-01 11:38 ` pault at gcc dot gnu.org
  2024-04-02 11:30 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu.org @ 2024-04-01 11:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 57839
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57839&action=edit
"Fix" for this PR

Even though no entities of type 'vs' are being referenced in subroutine iss,
gfortran currently feels the need to generate a final wrapper for it. The
comment in the patch explains what is happening but not why. I suspect that the
evil is being done somewhere in resolve.cc and will investigate in another
session.

Note the comments in the testcase below:

module d
  implicit none
contains
  function en() result(dd)
    use :: iv
    implicit none
    type(vs) :: dd
    dd%i = 1
  end function en
end module d

! Comment out line 1 and all brands complain that 'vs' is an undefined type
! Comment out line 1 and line 2 allows compilation to proceed (with fix for
gfortran)
module ni
  implicit none
contains
  subroutine iss()
    use :: iv                                        ! line 1
    use :: d
    implicit none
    type(vs) :: ans; ans = en(); print *, ctr, ans%i ! line 2
  end subroutine iss
end module ni

  use ni
  call iss()
  call iss()
!  print *, ctr
end

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

* [Bug fortran/114535] [13/14 regression] ICE with elemental finalizer
  2024-03-31  6:59 [Bug fortran/114535] New: ICE with elemental finalizer abensonca at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-04-01 11:38 ` pault at gcc dot gnu.org
@ 2024-04-02 11:30 ` rguenth at gcc dot gnu.org
  2024-04-09 14:27 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-04-02 11:30 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.3
           Priority|P3                          |P4

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

* [Bug fortran/114535] [13/14 regression] ICE with elemental finalizer
  2024-03-31  6:59 [Bug fortran/114535] New: ICE with elemental finalizer abensonca at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-04-02 11:30 ` rguenth at gcc dot gnu.org
@ 2024-04-09 14:27 ` cvs-commit at gcc dot gnu.org
  2024-05-08  8:03 ` [Bug fortran/114535] [13 " cvs-commit at gcc dot gnu.org
  2024-05-08  8:04 ` pault at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-09 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Paul Thomas <pault@gcc.gnu.org>:

https://gcc.gnu.org/g:de82b0cf981e49a0bda957c0ac31146b17407e23

commit r14-9874-gde82b0cf981e49a0bda957c0ac31146b17407e23
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Tue Apr 9 15:27:28 2024 +0100

    Fortran: Fix ICE in trans-stmt.cc(gfc_trans_call) [PR114535]

    2024-04-09  Paul Thomas  <pault@gcc.gnu.org>

    gcc/fortran
            PR fortran/114535
            * resolve.cc (resolve_symbol): Remove last chunk that checked
            for finalization of unreferenced symbols.

    gcc/testsuite/
            PR fortran/114535
            * gfortran.dg/pr114535d.f90: New test.
            * gfortran.dg/pr114535iv.f90: Additional source.

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

* [Bug fortran/114535] [13 regression] ICE with elemental finalizer
  2024-03-31  6:59 [Bug fortran/114535] New: ICE with elemental finalizer abensonca at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-04-09 14:27 ` cvs-commit at gcc dot gnu.org
@ 2024-05-08  8:03 ` cvs-commit at gcc dot gnu.org
  2024-05-08  8:04 ` pault at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-08  8:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Paul Thomas <pault@gcc.gnu.org>:

https://gcc.gnu.org/g:9fd6f7e912415f426382099d6aa182fd2b8ebb82

commit r13-8714-g9fd6f7e912415f426382099d6aa182fd2b8ebb82
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Tue Apr 9 15:27:28 2024 +0100

    Fortran: Fix ICE in trans-stmt.cc(gfc_trans_call) [PR114535]

    2024-04-09  Paul Thomas  <pault@gcc.gnu.org>

    gcc/fortran
            PR fortran/114535
            * resolve.cc (resolve_symbol): Remove last chunk that checked
            for finalization of unreferenced symbols.

    gcc/testsuite/
            PR fortran/114535
            * gfortran.dg/pr114535d.f90: New test.
            * gfortran.dg/pr114535iv.f90: Additional source.

    (cherry picked from commit de82b0cf981e49a0bda957c0ac31146b17407e23)

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

* [Bug fortran/114535] [13 regression] ICE with elemental finalizer
  2024-03-31  6:59 [Bug fortran/114535] New: ICE with elemental finalizer abensonca at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-05-08  8:03 ` [Bug fortran/114535] [13 " cvs-commit at gcc dot gnu.org
@ 2024-05-08  8:04 ` pault at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu.org @ 2024-05-08  8:04 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
Fixed on 13- through 15-branch. Thanks for the report.

Paul

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

end of thread, other threads:[~2024-05-08  8:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-31  6:59 [Bug fortran/114535] New: ICE with elemental finalizer abensonca at gcc dot gnu.org
2024-03-31 11:43 ` [Bug fortran/114535] " pault at gcc dot gnu.org
2024-03-31 11:50 ` [Bug fortran/114535] [13/14 regression] " pault at gcc dot gnu.org
2024-03-31 16:33 ` abensonca at gcc dot gnu.org
2024-04-01 11:38 ` pault at gcc dot gnu.org
2024-04-02 11:30 ` rguenth at gcc dot gnu.org
2024-04-09 14:27 ` cvs-commit at gcc dot gnu.org
2024-05-08  8:03 ` [Bug fortran/114535] [13 " cvs-commit at gcc dot gnu.org
2024-05-08  8:04 ` pault 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).