public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49430] New: ICE with allocatable length character in interface block
@ 2011-06-15 23:14 shadowblade at altern dot org
  2011-06-15 23:44 ` [Bug fortran/49430] " burnus at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: shadowblade at altern dot org @ 2011-06-15 23:14 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: ICE with allocatable length character in interface
                    block
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: shadowblade@altern.org


The following code:

module mod_test3
    abstract interface
        function messageProcedure(code) result(message)
            integer, intent(in) :: code
            character(:), allocatable :: message
        end function
    end interface

    type, public :: ctype
        procedure(messageProcedure), pointer, nopass :: getMessage => null()
    end type

contains
    subroutine asub(this, num)
        class(ctype), intent(in) :: this
        integer, intent(in) :: num
        character(:), allocatable :: message

        if(associated(this%getMessage)) message = this%getMessage(num)
    end subroutine
end module


causes this:
‘
In function ‘asub’:
Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


gfortran version:
Using built-in specs.
COLLECT_GCC=gfortran47
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin10.6.0/4.7.0/lto-wrapper
Target: x86_64-apple-darwin10.6.0
Configured with: ../gcc-4.7-20110611/configure --program-suffix=47
--prefix=/usr/local/ : (reconfigured) ../gcc-4.7-20110611/configure
--program-suffix=47 --prefix=/usr/local/ --enable-lto
--enable-languages=c,c++,objc,obj-c++,fortran
Thread model: posix
gcc version 4.7.0 20110611 (experimental) (GCC)


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

* [Bug fortran/49430] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
@ 2011-06-15 23:44 ` burnus at gcc dot gnu.org
  2011-06-21 19:41 ` janus at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-06-15 23:44 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |burnus at gcc dot gnu.org
             Blocks|                            |45170

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-06-15 23:43:42 UTC ---
I get:

test.f90:19:0: internal compiler error: tree check: expected tree that contains
'typed' structure, have '�' in fold_convert_loc, at fold-const.c:1859

==14082== Invalid read of size 1
==14082==    at 0x72F9B2: fold_convert_loc (fold-const.c:1859)
==14082==    by 0xA7D3F6: build_range_type_1 (tree.c:7170)
==14082==    by 0x5C8C69: gfc_get_character_type_len_for_eltype
(trans-types.c:977)
==14082==    by 0x59EA63: gfc_conv_procedure_call (trans-expr.c:3538)
==14082==    by 0x59F271: gfc_conv_function_expr (trans-expr.c:4082)
==14082==    by 0x597D01: gfc_trans_assignment_1 (trans-expr.c:6112)

In trans-expr.c:3538:
(gdb) p *ts.u.cl
$2 = {length = 0x0, next = 0x0, length_from_typespec = 215 '\327',
      backend_decl = 0x1535340, passed_length = 0x2aaaacdd7f00,
      resolved = 6764539}

I wonder whether the
3538              type = gfc_get_character_type (ts.kind, ts.u.cl);
should be rather:
   type = gfc_get_character_type (ts.kind, ts->deferred ? NULL_TREE : ts.u.cl);


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

* [Bug fortran/49430] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
  2011-06-15 23:44 ` [Bug fortran/49430] " burnus at gcc dot gnu.org
@ 2011-06-21 19:41 ` janus at gcc dot gnu.org
  2011-06-21 20:22 ` janus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-21 19:41 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janus at gcc dot gnu.org

--- Comment #2 from janus at gcc dot gnu.org 2011-06-21 19:40:25 UTC ---
The same error occurs for the test case in PR 49112 comment 7:


module datetime_mod

    implicit none
    private

    type :: DateTime
    contains
        procedure :: getFormattedString
    end type

contains

    function getTimeString(dt, FMT) result(string)
        character(:), allocatable :: string
        class(DateTime), intent(IN) :: dt
        integer, optional, intent(IN) :: FMT

        string = dt%getFormattedString(2, FMT)
    end function 

    function getFormattedString(this, FILTER, FMT) &
        result(string)
        character(:), allocatable :: string
        class(DateTime), intent(IN) :: this
        integer, optional, intent(IN) :: FILTER, FMT

    end function

end module 


c7.f90: In function ‘gettimestring’:
c7.f90:18:0: internal compiler error: tree check: expected tree that contains
‘typed’ structure, have ‘’ in fold_convert_loc, at fold-const.c:1859


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

* [Bug fortran/49430] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
  2011-06-15 23:44 ` [Bug fortran/49430] " burnus at gcc dot gnu.org
  2011-06-21 19:41 ` janus at gcc dot gnu.org
@ 2011-06-21 20:22 ` janus at gcc dot gnu.org
  2011-06-21 21:19 ` janus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-21 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.06.21 20:21:29
     Ever Confirmed|0                           |1

--- Comment #3 from janus at gcc dot gnu.org 2011-06-21 20:21:29 UTC ---
(In reply to comment #1)
> I wonder whether the
> 3538              type = gfc_get_character_type (ts.kind, ts.u.cl);
> should be rather:
>    type = gfc_get_character_type (ts.kind, ts->deferred ? NULL_TREE : ts.u.cl);

Well, with this:


Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c    (revision 175256)
+++ gcc/fortran/trans-expr.c    (working copy)
@@ -3535,7 +3535,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol *
       else if (ts.type == BT_CHARACTER)
     {
       /* Pass the string length.  */
-      type = gfc_get_character_type (ts.kind, ts.u.cl);
+      type = gfc_get_character_type (ts.kind,
+                     ts.deferred ? NULL_TREE : ts.u.cl);
       type = build_pointer_type (type);

       /* Return an address to a char[0:len-1]* temporary for


I run into another segfault:


#0  0x0000000000575a6d in gfc_evaluate_now_loc (loc=2308, expr=0x0,
pblock=0x7fffffffd560) at /home/jweil/gcc47/trunk/gcc/fortran/trans.c:126
#1  0x0000000000575b40 in gfc_evaluate_now (expr=0x0, pblock=0x7fffffffd560) at
/home/jweil/gcc47/trunk/gcc/fortran/trans.c:139
#2  0x00000000005ca23b in gfc_trans_assignment_1 (expr1=0x1af3df0,
expr2=0x1af3eb0, init_flag=0 '\000', dealloc=1 '\001')
    at /home/jweil/gcc47/trunk/gcc/fortran/trans-expr.c:6117


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

* [Bug fortran/49430] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
                   ` (2 preceding siblings ...)
  2011-06-21 20:22 ` janus at gcc dot gnu.org
@ 2011-06-21 21:19 ` janus at gcc dot gnu.org
  2011-06-21 21:37 ` janus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-21 21:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from janus at gcc dot gnu.org 2011-06-21 21:18:50 UTC ---
Slightly reduced/modified test case, giving a different error:


  abstract interface
    function messageProcedure()
      character(:), allocatable :: messageProcedure
    end function
  end interface

  type :: ctype
    procedure(messageProcedure), pointer, nopass :: getMessage
  end type

  type(ctype) :: this
  character :: message
  message = this%getMessage()

end


internal compiler error: vector VEC(tree,base) index domain error, in
gfc_conv_procedure_call at fortran/trans-expr.c:3387


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

* [Bug fortran/49430] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
                   ` (3 preceding siblings ...)
  2011-06-21 21:19 ` janus at gcc dot gnu.org
@ 2011-06-21 21:37 ` janus at gcc dot gnu.org
  2011-06-27 17:05 ` [Bug fortran/49430] [F03] " janus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-21 21:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from janus at gcc dot gnu.org 2011-06-21 21:37:27 UTC ---
Comment #4 can be fixed with the following patch:


Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c    (revision 175256)
+++ gcc/fortran/trans-expr.c    (working copy)
@@ -3381,7 +3381,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol *
          we take the character length of the first argument for the result.
          For dummies, we have to look through the formal argument list for
          this function and use the character length found there.*/
-      if (ts.deferred && (sym->attr.allocatable || sym->attr.pointer))
+      if (ts.deferred)
         cl.backend_decl = gfc_create_var (gfc_charlen_type_node, "slen");
       else if (!sym->attr.dummy)
         cl.backend_decl = VEC_index (tree, stringargs, 0);
@@ -6112,7 +6112,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr
   gfc_conv_expr (&rse, expr2);

   /* Stabilize a string length for temporaries.  */
-  if (expr2->ts.type == BT_CHARACTER)
+  if (expr2->ts.type == BT_CHARACTER && !expr2->ts.deferred)
     string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
   else
     string_length = NULL_TREE;


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

* [Bug fortran/49430] [F03] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
                   ` (4 preceding siblings ...)
  2011-06-21 21:37 ` janus at gcc dot gnu.org
@ 2011-06-27 17:05 ` janus at gcc dot gnu.org
  2012-05-13 11:21 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-27 17:05 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE with allocatable length |[F03] ICE with allocatable
                   |character in interface      |length character in
                   |block                       |interface block

--- Comment #6 from janus at gcc dot gnu.org 2011-06-27 15:07:15 UTC ---
The combined patches of comment #3 and #5 regtest cleanly, but do not fully fix
the original test case, cf. comment #3.


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

* [Bug fortran/49430] [F03] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
                   ` (5 preceding siblings ...)
  2011-06-27 17:05 ` [Bug fortran/49430] [F03] " janus at gcc dot gnu.org
@ 2012-05-13 11:21 ` burnus at gcc dot gnu.org
  2012-05-13 11:38 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-13 11:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-13 10:52:38 UTC ---
Author: burnus
Date: Sun May 13 10:52:32 2012
New Revision: 187436

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187436
Log:
2012-05-13  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
            Tobias Burnus  <burnus@net-b.de>

        PR fortran/52158
        PR fortran/45170
        PR fortran/49430
        * resolve.c (resolve_fl_derived0): Deferred character length 
        procedure components are supported.
        * trans-expr.c (gfc_conv_procedure_call): Handle TBP with 
        deferred-length results.
        (gfc_string_to_single_character): Add a new check to prevent
        NULL read.
        (gfc_conv_procedure_call): Remove unuseful checks on 
        symbol's attributes. Add new checks to prevent NULL read on
        string length. 

2012-05-13  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>

        PR fortran/45170
        * gfortran.dg/deferred_type_param_3.f90: New.
        * gfortran.dg/deferred_type_proc_pointer_1.f90: New.
        * gfortran.dg/deferred_type_proc_pointer_2.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/deferred_type_param_3.f90
    trunk/gcc/testsuite/gfortran.dg/deferred_type_proc_pointer_1.f90
    trunk/gcc/testsuite/gfortran.dg/deferred_type_proc_pointer_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/49430] [F03] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
                   ` (6 preceding siblings ...)
  2012-05-13 11:21 ` burnus at gcc dot gnu.org
@ 2012-05-13 11:38 ` burnus at gcc dot gnu.org
  2012-09-25 16:15 ` dtemirbulatov at gmail dot com
  2012-09-25 16:17 ` dtemirbulatov at gmail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-13 11:38 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

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

--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-13 11:31:23 UTC ---
FIXED on the trunk (GCC 4.8).

Thanks for the bug report and sorry for taking nearly one year to get it fixed.


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

* [Bug fortran/49430] [F03] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
                   ` (7 preceding siblings ...)
  2012-05-13 11:38 ` burnus at gcc dot gnu.org
@ 2012-09-25 16:15 ` dtemirbulatov at gmail dot com
  2012-09-25 16:17 ` dtemirbulatov at gmail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: dtemirbulatov at gmail dot com @ 2012-09-25 16:15 UTC (permalink / raw)
  To: gcc-bugs


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

Dinar Temirbulatov <dtemirbulatov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dtemirbulatov at gmail dot
                   |                            |com

--- Comment #9 from Dinar Temirbulatov <dtemirbulatov at gmail dot com> 2012-09-25 16:15:11 UTC ---
(gdb) call debug_rtx(insn)
(insn:TI 454 460 607 (set (reg:SI 2 r2 [orig:433 buf+2 ] [433])
        (zero_extend:SI (mem/u/c/i:QI (symbol_ref/u:SI ("*.LC0") [flags 0x2])
[0 S1 A8]))) cr_parse-reduced.ii:111 168 {*arm_zero_extendqisi2_v6}
     (nil))


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

* [Bug fortran/49430] [F03] ICE with allocatable length character in interface block
  2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
                   ` (8 preceding siblings ...)
  2012-09-25 16:15 ` dtemirbulatov at gmail dot com
@ 2012-09-25 16:17 ` dtemirbulatov at gmail dot com
  9 siblings, 0 replies; 11+ messages in thread
From: dtemirbulatov at gmail dot com @ 2012-09-25 16:17 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #10 from Dinar Temirbulatov <dtemirbulatov at gmail dot com> 2012-09-25 16:16:55 UTC ---
oh, sorry please ignore my comment


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

end of thread, other threads:[~2012-09-25 16:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-15 23:14 [Bug fortran/49430] New: ICE with allocatable length character in interface block shadowblade at altern dot org
2011-06-15 23:44 ` [Bug fortran/49430] " burnus at gcc dot gnu.org
2011-06-21 19:41 ` janus at gcc dot gnu.org
2011-06-21 20:22 ` janus at gcc dot gnu.org
2011-06-21 21:19 ` janus at gcc dot gnu.org
2011-06-21 21:37 ` janus at gcc dot gnu.org
2011-06-27 17:05 ` [Bug fortran/49430] [F03] " janus at gcc dot gnu.org
2012-05-13 11:21 ` burnus at gcc dot gnu.org
2012-05-13 11:38 ` burnus at gcc dot gnu.org
2012-09-25 16:15 ` dtemirbulatov at gmail dot com
2012-09-25 16:17 ` dtemirbulatov at gmail dot com

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).