public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51970] New: gimplification failed for an avatar of pr51948
@ 2012-01-23 17:37 dominiq at lps dot ens.fr
  2012-01-23 18:01 ` [Bug fortran/51970] " burnus at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2012-01-23 17:37 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51970
           Summary: gimplification failed for an avatar of pr51948
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dominiq@lps.ens.fr
                CC: burnus@net-b.de


Compiling the following (invalid?) avatar of pr51948

type t
end type t

contains
  function func(x)
    class(t), allocatable :: x(:), func2(:)
    call move_alloc (x, func2)
! FAILS: Error: the 'from' and 'to' arguments of 'move_alloc' intrinsic at (1)
must have the same rank 0/1
  end function

  function func2(x)
    type(t), allocatable :: x
    class(t), allocatable :: func2
    call move_alloc (x, func2)
! FAILS: Error: 'to' argument of 'move_alloc' intrinsic at (1) must be a
variable
  end function
end

gives the following ICE

gimplification failed:
&func2._data <addr_expr 0x142d38550
    type <pointer_type 0x142d332a0
        type <record_type 0x142d2fdc8 array1_t type_1 BLK
            size <integer_cst 0x142d0db80 constant 384>
            unit size <integer_cst 0x142d0d600 constant 48>
            align 64 symtab 0 alias set -1 canonical type 0x142d2fe70 fields
<field_decl 0x142d21a18 data>
            pointer_to_this <pointer_type 0x142d332a0> chain <type_decl
0x142d310b8 D.1886>>
        public unsigned DI
        size <integer_cst 0x142c0c940 constant 64>
        unit size <integer_cst 0x142c0c960 constant 8>
        align 64 symtab 0 alias set -1 canonical type 0x142d33348>

    arg 0 <component_ref 0x142d0c540 type <record_type 0x142d2fdc8 array1_t>

        arg 0 <var_decl 0x142c0e640 func2 type <record_type 0x142d2f9d8
__class_MAIN___T_1_a>
            addressable used BLK file pr51948_db.f90 line 6 col 0
            size <integer_cst 0x142d0d820 constant 448>
            unit size <integer_cst 0x142d0d860 constant 56>
            align 64 context <function_decl 0x142d2a500 func>>
        arg 1 <field_decl 0x142d32130 _data type <record_type 0x142d2fdc8
array1_t>
            BLK file pr51948_db.f90 line 6 col 0 size <integer_cst 0x142d0db80
384> unit size <integer_cst 0x142d0d600 48>
            align 64 offset_align 128
            offset <integer_cst 0x142c0c980 constant 0>
            bit offset <integer_cst 0x142c0c9e0 constant 0> context
<record_type 0x142d2f9d8 __class_MAIN___T_1_a> chain <field_decl 0x142d321c8
_vptr>>
        pr51948_db.f90:7:0>
    pr51948_db.f90:7:0>
pr51948_db.f90: In function 'func':
pr51948_db.f90:7:0: internal compiler error: gimplification failed

This may due to the patch at
http://gcc.gnu.org/ml/fortran/2012-01/msg00213.html . The code is accepted by
trunk r183357.


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

* [Bug fortran/51970] gimplification failed for an avatar of pr51948
  2012-01-23 17:37 [Bug fortran/51970] New: gimplification failed for an avatar of pr51948 dominiq at lps dot ens.fr
@ 2012-01-23 18:01 ` burnus at gcc dot gnu.org
  2012-01-24 10:41 ` [Bug fortran/51970] [OOP] gimplification failed for polymorphic MOVE_ALLOC dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-23 18:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|burnus@net-b.de             |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-23 17:43:32 UTC ---
(In reply to comment #0)
> The code is accepted by trunk r183357.

And it crashes in the same way with 4.7.0 2012-01-18 trunk revision 183273.

(In any case it is not a (real) regression as GCC 4.6 didn't support
polymorphic arrays.)


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

* [Bug fortran/51970] [OOP] gimplification failed for polymorphic MOVE_ALLOC
  2012-01-23 17:37 [Bug fortran/51970] New: gimplification failed for an avatar of pr51948 dominiq at lps dot ens.fr
  2012-01-23 18:01 ` [Bug fortran/51970] " burnus at gcc dot gnu.org
@ 2012-01-24 10:41 ` dominiq at lps dot ens.fr
  2012-01-24 16:03 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2012-01-24 10:41 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-01-24
     Ever Confirmed|0                           |1

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-01-24 10:22:19 UTC ---
> And it crashes in the same way with 4.7.0 2012-01-18 trunk revision 183273.

So marked as NEW.


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

* [Bug fortran/51970] [OOP] gimplification failed for polymorphic MOVE_ALLOC
  2012-01-23 17:37 [Bug fortran/51970] New: gimplification failed for an avatar of pr51948 dominiq at lps dot ens.fr
  2012-01-23 18:01 ` [Bug fortran/51970] " burnus at gcc dot gnu.org
  2012-01-24 10:41 ` [Bug fortran/51970] [OOP] gimplification failed for polymorphic MOVE_ALLOC dominiq at lps dot ens.fr
@ 2012-01-24 16:03 ` burnus at gcc dot gnu.org
  2012-01-24 23:01 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-24 16:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-24 15:27:43 UTC ---
Created attachment 26443
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26443
Draft patch for trans-intrinsic.c

There are two issues:

a) from_expr->rank *and* to_expr->rank are 0 instead of 1.
   That's a variant of the issue of PR 51977.

b) trans-intrinsic.c's conv_move_alloc does not properly handle polymorphic
   arrays.

For (b) a draft patch is attached. TODO: Regtest it, try combinations of TYPE
and CLASS, try CLASS with allocatable components - and CLASS components.


To use it, you need to either fix issue (a) or you can try the following hack:

--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -2726,0 +2727,5 @@ gfc_check_move_alloc (gfc_expr *from, gfc_expr *to)
+  /* THIS IS A HACK! */
+  if (from->ts.type == BT_CLASS && CLASS_DATA (from)->attr.dimension)
+    from->rank = CLASS_DATA (from)->as->rank;
+  if (to->ts.type == BT_CLASS && CLASS_DATA (to)->attr.dimension)
+    to->rank = CLASS_DATA (to)->as->rank;


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

* [Bug fortran/51970] [OOP] gimplification failed for polymorphic MOVE_ALLOC
  2012-01-23 17:37 [Bug fortran/51970] New: gimplification failed for an avatar of pr51948 dominiq at lps dot ens.fr
                   ` (2 preceding siblings ...)
  2012-01-24 16:03 ` burnus at gcc dot gnu.org
@ 2012-01-24 23:01 ` dominiq at lps dot ens.fr
  2012-01-27 13:12 ` burnus at gcc dot gnu.org
  2012-01-27 13:18 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2012-01-24 23:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-01-24 22:35:43 UTC ---
The patch attached to comment #4 + the "hack" let the test compile without
error (although I don't know if it is valid). I have noticed the following
changes:

For 51948, before the patch I had two errors

[macbook] f90/bug% gfc pr51948.f90
pr51948.f90:14.24:

    call move_alloc (x, func)
                        1
Error: 'to' argument of 'move_alloc' intrinsic at (1) must be a variable
pr51948.f90:7.24:

    call move_alloc (x, func)
                        1
Error: the 'from' and 'to' arguments of 'move_alloc' intrinsic at (1) must have
the same rank 0/1

After the patch I have only one

[macbook] f90/bug% gfc pr51948.f90
pr51948.f90:14.24:

    call move_alloc (x, func)
                        1
Error: 'to' argument of 'move_alloc' intrinsic at (1) must be a variable

For another avatar and the test in pr51977, the error is replaced by an ICE:
before the patch

[macbook] f90/bug% gfc pr51948_db_1.f90
pr51948_db_1.f90:7.24:

    call move_alloc (x, func)
                        1
Error: the 'from' and 'to' arguments of 'move_alloc' intrinsic at (1) must have
the same rank 0/1

after the patch

[macbook] f90/bug% gfc pr51948_db_1.f90
pr51948_db_1.f90: In function 'func':
pr51948_db_1.f90:9:0: internal compiler error: in fold_convert_loc, at
fold-const.c:2016


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

* [Bug fortran/51970] [OOP] gimplification failed for polymorphic MOVE_ALLOC
  2012-01-23 17:37 [Bug fortran/51970] New: gimplification failed for an avatar of pr51948 dominiq at lps dot ens.fr
                   ` (3 preceding siblings ...)
  2012-01-24 23:01 ` dominiq at lps dot ens.fr
@ 2012-01-27 13:12 ` burnus at gcc dot gnu.org
  2012-01-27 13:18 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-27 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-27 13:08:58 UTC ---
Author: burnus
Date: Fri Jan 27 13:08:52 2012
New Revision: 183622

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183622
Log:
2012-01-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51970
        PR fortran/51977
        * primary.c (gfc_match_varspec. gfc_match_rvalue): Set
        handle array spec for BT_CLASS.
        * expr.c (gfc_get_variable_expr, gfc_lval_expr_from_sym)
        * frontend-passes.c (create_var): Ditto.
        * resolve.c (resolve_actual_arglist, resolve_assoc_var): Ditto.
        * trans-decl.c (gfc_trans_deferred_vars): Use class_pointer
        instead of attr.pointer.
        (gfc_generate_function_code): Use CLASS_DATA (sym) for BT_CLASS.
        * trans-intrinsic.c (conv_intrinsic_move_alloc): Move assert.
        * trans-stmt.c (trans_associate_var): Ask for the descriptor.

2012-01-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51970
        PR fortran/51977
        * gfortran.dg/move_alloc_13.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/move_alloc_13.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/frontend-passes.c
    trunk/gcc/fortran/primary.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/51970] [OOP] gimplification failed for polymorphic MOVE_ALLOC
  2012-01-23 17:37 [Bug fortran/51970] New: gimplification failed for an avatar of pr51948 dominiq at lps dot ens.fr
                   ` (4 preceding siblings ...)
  2012-01-27 13:12 ` burnus at gcc dot gnu.org
@ 2012-01-27 13:18 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-27 13:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-27 13:09:26 UTC ---
FIXED on the trunk (4.7).


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

end of thread, other threads:[~2012-01-27 13:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-23 17:37 [Bug fortran/51970] New: gimplification failed for an avatar of pr51948 dominiq at lps dot ens.fr
2012-01-23 18:01 ` [Bug fortran/51970] " burnus at gcc dot gnu.org
2012-01-24 10:41 ` [Bug fortran/51970] [OOP] gimplification failed for polymorphic MOVE_ALLOC dominiq at lps dot ens.fr
2012-01-24 16:03 ` burnus at gcc dot gnu.org
2012-01-24 23:01 ` dominiq at lps dot ens.fr
2012-01-27 13:12 ` burnus at gcc dot gnu.org
2012-01-27 13:18 ` burnus 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).