public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension
@ 2013-09-18 22:57 abensonca at gmail dot com
  2013-09-20  8:47 ` [Bug fortran/58470] [OOP] ICE on invalid with FINAL procedure " janus at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: abensonca at gmail dot com @ 2013-09-18 22:57 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 7735 bytes --]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

            Bug ID: 58470
           Summary: ICE on invalid with FINAL function and type extension
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: abensonca at gmail dot com

The following causes an ICE with gfortran 4.9.0 (r202667):

module cf
  type  :: cfml
   contains
     final :: mld
  end type cfml
  type, extends(cfml) :: cfmde
  end type cfmde
contains
  subroutine mld(s)
    class(cfml), intent(inout) :: s
  end subroutine mld
end module cf

$ gfortran -v
Using built-in specs.
COLLECT_GCC=/opt/gcc-trunk/bin/gfortran
COLLECT_LTO_WRAPPER=/opt/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/opt/gcc-trunk
--enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 4.9.0 20130917 (experimental) (GCC) 

$ gfortran -c bug.F90 -o bug.o
bug.F90: In function ‘__final_cf_Cfml’:
bug.F90:12:0: internal compiler error: Segmentation fault
 end module cf
 ^
0x99112f crash_signal
        ../../gcc-trunk/gcc/toplev.c:335
0x5f8e0c gfc_conv_derived_to_class(gfc_se*, gfc_expr*, gfc_typespec,
tree_node*, bool, bool)
        ../../gcc-trunk/gcc/fortran/trans-expr.c:424
0x5f1140 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
        ../../gcc-trunk/gcc/fortran/trans-expr.c:4028
0x61cd04 gfc_trans_call(gfc_code*, bool, tree_node*, tree_node*, bool)
        ../../gcc-trunk/gcc/fortran/trans-stmt.c:406
0x5bf010 trans_code
        ../../gcc-trunk/gcc/fortran/trans.c:1700
0x621a40 gfc_trans_integer_select
        ../../gcc-trunk/gcc/fortran/trans-stmt.c:1990
0x621a40 gfc_trans_select(gfc_code*)
        ../../gcc-trunk/gcc/fortran/trans-stmt.c:2484
0x5bed77 trans_code
        ../../gcc-trunk/gcc/fortran/trans.c:1743
0x5e7dae gfc_generate_function_code(gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/trans-decl.c:5528
0x5c0781 gfc_generate_module_code(gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/trans.c:1955
0x57eee7 translate_all_program_units
        ../../gcc-trunk/gcc/fortran/parse.c:4496
0x57eee7 gfc_parse_file()
        ../../gcc-trunk/gcc/fortran/parse.c:4706
0x5baab5 gfc_be_parse_file
        ../../gcc-trunk/gcc/fortran/f95-lang.c:189
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

The code is invalid because the finalization subroutine defines its argument as
CLASS rather than TYPE. Removing the "cfmde" type (or removing the ",
extends(cfml)") results in the correct error message:

$ gfortran -c bug.F90 -o bug.o
bug.F90:9.18:

  subroutine mld(s)
                  1
Error: Argument of FINAL procedure at (1) must be of type 'cfml'
>From gcc-bugs-return-430147-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Sep 18 23:01:56 2013
Return-Path: <gcc-bugs-return-430147-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 4873 invoked by alias); 18 Sep 2013 23:01:56 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 4849 invoked by uid 48); 18 Sep 2013 23:01:53 -0000
From: "abensonca at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/58471] New: ICE on invalid with missing type constructor and -Wall
Date: Wed, 18 Sep 2013 23:01:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: abensonca at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-58471-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-09/txt/msg01387.txt.bz2
Content-length: 2774

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX471

            Bug ID: 58471
           Summary: ICE on invalid with missing type constructor and -Wall
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: abensonca at gmail dot com

The following causes an ICE with gfortran 4.9.0 (r202667) when compiled with
-Wall:

module cf
  type :: cfmde
  end type cfmde
  interface cfmde
     module procedure mdedc
  end interface cfmde
contains
  subroutine cfi()
    implicit none
    type(cfmde), pointer :: cfd
    cfdÏmde()
    return
  end subroutine cfi
end module cf

$ gfortran -v
Using built-in specs.
COLLECT_GCC=/opt/gcc-trunk/bin/gfortran
COLLECT_LTO_WRAPPER=/opt/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/opt/gcc-trunk
--enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 4.9.0 20130917 (experimental) (GCC)

$ gfortran -c bug1.F90 -o bug1.o -Wall
bug1.F90:5.22:

     module procedure mdedc
                      1
Error: Procedure 'mdedc' in generic interface 'cfmde' at (1) is neither
function nor subroutine
f951: internal compiler error: Segmentation fault
0x99112f crash_signal
        ../../gcc-trunk/gcc/toplev.c:335
0x582892 gfc_expr_attr(gfc_expr*)
        ../../gcc-trunk/gcc/fortran/primary.c:2259
0x53a40c gfc_check_assign(gfc_expr*, gfc_expr*, int)
        ../../gcc-trunk/gcc/fortran/expr.c:3160
0x58f872 resolve_ordinary_assign
        ../../gcc-trunk/gcc/fortran/resolve.c:9200
0x58f872 resolve_code
        ../../gcc-trunk/gcc/fortran/resolve.c:9810
0x591b0e resolve_codes
        ../../gcc-trunk/gcc/fortran/resolve.c:14507
0x591a17 resolve_codes
        ../../gcc-trunk/gcc/fortran/resolve.c:14493
0x591bf2 gfc_resolve
        ../../gcc-trunk/gcc/fortran/resolve.c:14535
0x57efdf gfc_parse_file()
        ../../gcc-trunk/gcc/fortran/parse.c:4645
0x5baab5 gfc_be_parse_file
        ../../gcc-trunk/gcc/fortran/f95-lang.c:189
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

without -Wall the correct error message is generated:
$ gfortran -c bug1.F90 -o bug1.o
bug1.F90:5.22:

     module procedure mdedc
                      1
Error: Procedure 'mdedc' in generic interface 'cfmde' at (1) is neither
function nor subroutine
bug1.F90:11.8:

    cfdÏmde()
        1
Error: Can't convert REAL(4) to TYPE(cfmde) at (1)

Adding a suitable "mdedc" procedure results in successful compilation.


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

* [Bug fortran/58470] [OOP] ICE on invalid with FINAL procedure and type extension
  2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
@ 2013-09-20  8:47 ` janus at gcc dot gnu.org
  2014-01-11 10:26 ` [Bug fortran/58470] [4.9 Regression] " janus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2013-09-20  8:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-09-20
                 CC|                            |janus at gcc dot gnu.org
            Summary|ICE on invalid with FINAL   |[OOP] ICE on invalid with
                   |function and type extension |FINAL procedure and type
                   |                            |extension
     Ever confirmed|0                           |1

--- Comment #1 from janus at gcc dot gnu.org ---
Confirmed. I don't see why the error is not thrown before the ICE ...


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

* [Bug fortran/58470] [4.9 Regression] [OOP] ICE on invalid with FINAL procedure and type extension
  2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
  2013-09-20  8:47 ` [Bug fortran/58470] [OOP] ICE on invalid with FINAL procedure " janus at gcc dot gnu.org
@ 2014-01-11 10:26 ` janus at gcc dot gnu.org
  2014-01-11 11:42 ` janus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-11 10:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[OOP] ICE on invalid with   |[4.9 Regression] [OOP] ICE
                   |FINAL procedure and type    |on invalid with FINAL
                   |extension                   |procedure and type
                   |                            |extension

--- Comment #2 from janus at gcc dot gnu.org ---
I think the problem is that generate_finalization_wrapper is called before
gfc_resolve_finalizers.

I am marking this as a regression, since 4.8 gives the correct error message.


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

* [Bug fortran/58470] [4.9 Regression] [OOP] ICE on invalid with FINAL procedure and type extension
  2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
  2013-09-20  8:47 ` [Bug fortran/58470] [OOP] ICE on invalid with FINAL procedure " janus at gcc dot gnu.org
  2014-01-11 10:26 ` [Bug fortran/58470] [4.9 Regression] " janus at gcc dot gnu.org
@ 2014-01-11 11:42 ` janus at gcc dot gnu.org
  2014-01-11 11:49 ` dominiq at lps dot ens.fr
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-11 11:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |janus at gcc dot gnu.org

--- Comment #3 from janus at gcc dot gnu.org ---
The following patch fixes it and is free of testsuite regressions:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c    (revision 206552)
+++ gcc/fortran/resolve.c    (working copy)
@@ -12455,10 +12455,6 @@ resolve_fl_derived0 (gfc_symbol *sym)
   /* Add derived type to the derived type list.  */
   add_dt_to_dt_list (sym);

-  /* Check if the type is finalizable. This is done in order to ensure that
the
-     finalization wrapper is generated early enough.  */
-  gfc_is_finalizable (sym, NULL);
-
   return true;
 }


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

* [Bug fortran/58470] [4.9 Regression] [OOP] ICE on invalid with FINAL procedure and type extension
  2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
                   ` (2 preceding siblings ...)
  2014-01-11 11:42 ` janus at gcc dot gnu.org
@ 2014-01-11 11:49 ` dominiq at lps dot ens.fr
  2014-01-11 12:05 ` janus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-01-11 11:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> The following patch fixes it and is free of testsuite regressions: ...

I am not sure (as in "I am pretty sure") that the finalization coverage in the
test suite (as well as in the real world) is enough. Removing a block which was
clearly written on purpose makes me nervous.


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

* [Bug fortran/58470] [4.9 Regression] [OOP] ICE on invalid with FINAL procedure and type extension
  2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
                   ` (3 preceding siblings ...)
  2014-01-11 11:49 ` dominiq at lps dot ens.fr
@ 2014-01-11 12:05 ` janus at gcc dot gnu.org
  2014-01-31 10:49 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-11 12:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

--- Comment #5 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #4)
> > The following patch fixes it and is free of testsuite regressions: ...
> 
> I am not sure (as in "I am pretty sure") that the finalization coverage in
> the test suite (as well as in the real world) is enough.

That is probably true.


> Removing a block
> which was clearly written on purpose makes me nervous.

Well, I guess all code is written "on purpose". What makes me nervous is
keeping code that serves no clear purpose. In particular the comment does not
really clarify the question "early enough for *what*" ?

Overall that line seems rather hackish to me. In any case it comes from:

http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=194104


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

* [Bug fortran/58470] [4.9 Regression] [OOP] ICE on invalid with FINAL procedure and type extension
  2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
                   ` (4 preceding siblings ...)
  2014-01-11 12:05 ` janus at gcc dot gnu.org
@ 2014-01-31 10:49 ` rguenth at gcc dot gnu.org
  2014-01-31 11:03 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-01-31 10:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.9.0


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

* [Bug fortran/58470] [4.9 Regression] [OOP] ICE on invalid with FINAL procedure and type extension
  2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
                   ` (5 preceding siblings ...)
  2014-01-31 10:49 ` rguenth at gcc dot gnu.org
@ 2014-01-31 11:03 ` rguenth at gcc dot gnu.org
  2014-02-08 21:33 ` janus at gcc dot gnu.org
  2014-02-08 21:36 ` janus at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-01-31 11:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5


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

* [Bug fortran/58470] [4.9 Regression] [OOP] ICE on invalid with FINAL procedure and type extension
  2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
                   ` (6 preceding siblings ...)
  2014-01-31 11:03 ` rguenth at gcc dot gnu.org
@ 2014-02-08 21:33 ` janus at gcc dot gnu.org
  2014-02-08 21:36 ` janus at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2014-02-08 21:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

--- Comment #6 from janus at gcc dot gnu.org ---
Author: janus
Date: Sat Feb  8 21:32:25 2014
New Revision: 207636

URL: http://gcc.gnu.org/viewcvs?rev=207636&root=gcc&view=rev
Log:
2014-02-08  Janus Weil  <janus@gcc.gnu.org>
        Mikael Morin <mikael.morin@gcc.gnu.org>

    PR fortran/58470
    * class.c (generate_finalization_wrapper): Assert that proc_tree has
    been set in gfc_resolve_finalizers.
    * resolve.c (resolve_fl_derived0): Remove unnecessary call to
    gfc_is_finalizable.


2014-02-08  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/58470
    * gfortran.dg/finalize_22.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/finalize_22.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/class.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/58470] [4.9 Regression] [OOP] ICE on invalid with FINAL procedure and type extension
  2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
                   ` (7 preceding siblings ...)
  2014-02-08 21:33 ` janus at gcc dot gnu.org
@ 2014-02-08 21:36 ` janus at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2014-02-08 21:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58470

janus at gcc dot gnu.org changed:

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

--- Comment #7 from janus at gcc dot gnu.org ---
Fixed with r207636. Closing.


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

end of thread, other threads:[~2014-02-08 21:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-18 22:57 [Bug fortran/58470] New: ICE on invalid with FINAL function and type extension abensonca at gmail dot com
2013-09-20  8:47 ` [Bug fortran/58470] [OOP] ICE on invalid with FINAL procedure " janus at gcc dot gnu.org
2014-01-11 10:26 ` [Bug fortran/58470] [4.9 Regression] " janus at gcc dot gnu.org
2014-01-11 11:42 ` janus at gcc dot gnu.org
2014-01-11 11:49 ` dominiq at lps dot ens.fr
2014-01-11 12:05 ` janus at gcc dot gnu.org
2014-01-31 10:49 ` rguenth at gcc dot gnu.org
2014-01-31 11:03 ` rguenth at gcc dot gnu.org
2014-02-08 21:33 ` janus at gcc dot gnu.org
2014-02-08 21:36 ` janus 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).