public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS
@ 2011-03-30 11:20 krefson at googlemail dot com
  2011-03-30 12:39 ` [Bug fortran/48360] [4.6/4.7 Regression] " burnus at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: krefson at googlemail dot com @ 2011-03-30 11:20 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: ICE on array assignment statement with allocatable LHS
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: krefson@googlemail.com


Created attachment 23816
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23816
Fortran 95 source which gives ICE on compilation attempt.

The attached code gives an ICE when compiled with gfortran 4.6.0 

$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.6/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.6-source/gcc-4.6-20110312/configure
--enable-languages=c,c++,fortran --enable-checking=release --disable-bootstrap
--disable-libmudflap --enable-libgomp --enable-lto --enable-gold
--with-plugin-ld=/usr/bin/gold --prefix=/usr/local/gcc-4.6
Thread model: posix
gcc version 4.6.0 20110312 (experimental) (GCC) 

$ gfortran -c gf46-ice.f90
gf46-ice.f90: In function ‘assignit’:
gf46-ice.f90:19:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Fine with 4.4.3 and 4.5

Disabling the possibility of "allocate-on-assignment" by changing

   hmat = mmv%h0

to
   hmat(:,:) = mmv%h0

compiles correctly.


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

* [Bug fortran/48360] [4.6/4.7 Regression] ICE on array assignment statement with allocatable LHS
  2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
@ 2011-03-30 12:39 ` burnus at gcc dot gnu.org
  2011-03-31 10:39 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-03-30 12:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |pault at gcc dot gnu.org
   Target Milestone|---                         |4.6.1
            Summary|ICE on array assignment     |[4.6/4.7 Regression] ICE on
                   |statement with allocatable  |array assignment statement
                   |LHS                         |with allocatable LHS

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-03-30 11:55:51 UTC ---
(In reply to comment #0)
> Disabling the possibility of "allocate-on-assignment" by changing
[...]

Or simply use: -fno-realloc-lhs


With my - admittedly not clean - tree, that gives the following valgrind
output:

Invalid read of size 8
    at 0x56B13A: get_std_lbound (trans-array.c:6825)
    by 0x573E88: gfc_alloc_allocatable_for_assignment (trans-array.c:7083)
    by 0x58EBDB: gfc_trans_assignment_1 (trans-expr.c:6186)

That's the lines:

6822      else if (expr->expr_type == EXPR_VARIABLE)
6823        {
6824          tmp = TREE_TYPE (expr->symtree->n.sym->backend_decl);
6825          return GFC_TYPE_ARRAY_LBOUND(tmp, dim);

The issue is that
  TYPE_LANG_SPECIFIC (tmp) == tmp->type.lang_specific == NULL
and, thus, accessing TYPE_LANG_SPECIFIC(node)->lbound[dim]  gives an ICE.

The issue is that for "mmv%h0" the proper backend is not:
  expr->symtree->n.sym->backend_decl
but rather
  expr->ref->u.c->component->backend_decl


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

* [Bug fortran/48360] [4.6/4.7 Regression] ICE on array assignment statement with allocatable LHS
  2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
  2011-03-30 12:39 ` [Bug fortran/48360] [4.6/4.7 Regression] " burnus at gcc dot gnu.org
@ 2011-03-31 10:39 ` jakub at gcc dot gnu.org
  2011-03-31 13:25 ` jvdelisle at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-31 10:39 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |jakub at gcc dot gnu.org


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

* [Bug fortran/48360] [4.6/4.7 Regression] ICE on array assignment statement with allocatable LHS
  2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
  2011-03-30 12:39 ` [Bug fortran/48360] [4.6/4.7 Regression] " burnus at gcc dot gnu.org
  2011-03-31 10:39 ` jakub at gcc dot gnu.org
@ 2011-03-31 13:25 ` jvdelisle at gcc dot gnu.org
  2011-03-31 13:37 ` jvdelisle at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-03-31 13:25 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

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

--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-03-31 13:05:01 UTC ---
I am a little suspicious of this:

 static int count_arglist;

+/* Pointer to an array of gfc_expr ** we operate on, plus its size
+   and counter.  */
+
+static gfc_expr ***expr_array;
+static int expr_size, expr_count;


It could be getting walked on or optimized away by the optimizers.  Is there
another way to do this that is less indirect or relies less on static.

Just seems too tricky.  I am not looking further on this one.


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

* [Bug fortran/48360] [4.6/4.7 Regression] ICE on array assignment statement with allocatable LHS
  2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
                   ` (2 preceding siblings ...)
  2011-03-31 13:25 ` jvdelisle at gcc dot gnu.org
@ 2011-03-31 13:37 ` jvdelisle at gcc dot gnu.org
  2011-04-01 17:54 ` jvdelisle at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-03-31 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-03-31 13:06:06 UTC ---
Disregard 2, wrong PR


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

* [Bug fortran/48360] [4.6/4.7 Regression] ICE on array assignment statement with allocatable LHS
  2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
                   ` (3 preceding siblings ...)
  2011-03-31 13:37 ` jvdelisle at gcc dot gnu.org
@ 2011-04-01 17:54 ` jvdelisle at gcc dot gnu.org
  2011-04-08  4:17 ` pault at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-04-01 17:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-04-01 17:54:06 UTC ---
This regression was caused by r167220.

Revision 167220 - (view) (download) (annotate) - [select for diffs]
Modified Sun Nov 28 13:47:26 2010 UTC (4 months ago) by pault


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

* [Bug fortran/48360] [4.6/4.7 Regression] ICE on array assignment statement with allocatable LHS
  2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
                   ` (4 preceding siblings ...)
  2011-04-01 17:54 ` jvdelisle at gcc dot gnu.org
@ 2011-04-08  4:17 ` pault at gcc dot gnu.org
  2011-04-12 19:15 ` pault at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2011-04-08  4:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.04.08 04:16:46
     Ever Confirmed|0                           |1

--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> 2011-04-08 04:16:46 UTC ---
This is obviously mine :-)

This fixes it but I suspect that a few more conditions (no ARRAY_ELEMENT for
example) will be needed for it to be correct.

Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c    (revision 171573)
--- gcc/fortran/trans-array.c    (working copy)
*************** get_std_lbound (gfc_expr *expr, tree des
*** 6707,6712 ****
--- 6707,6713 ----
    tree stride;
    tree cond, cond1, cond3, cond4;
    tree tmp;
+   gfc_ref *ref;
    if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc)))
      {
        tmp = gfc_rank_cst[dim];
*************** get_std_lbound (gfc_expr *expr, tree des
*** 6740,6745 ****
--- 6741,6752 ----
    else if (expr->expr_type == EXPR_VARIABLE)
      {
        tmp = TREE_TYPE (expr->symtree->n.sym->backend_decl);
+       for (ref = expr->ref; ref; ref = ref->next)
+     {
+       if (ref->type == REF_COMPONENT
+         && ref->u.c.component->as)
+         tmp = TREE_TYPE (ref->u.c.component->backend_decl);
+     }
        return GFC_TYPE_ARRAY_LBOUND(tmp, dim);
      }
    else if (expr->expr_type == EXPR_FUNCTION)

Paul


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

* [Bug fortran/48360] [4.6/4.7 Regression] ICE on array assignment statement with allocatable LHS
  2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
                   ` (5 preceding siblings ...)
  2011-04-08  4:17 ` pault at gcc dot gnu.org
@ 2011-04-12 19:15 ` pault at gcc dot gnu.org
  2011-04-13 18:38 ` pault at gcc dot gnu.org
  2011-04-13 19:20 ` pault at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2011-04-12 19:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> 2011-04-12 19:14:52 UTC ---
Author: pault
Date: Tue Apr 12 19:14:49 2011
New Revision: 172339

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172339
Log:
2011-04-12  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/48360
    PR fortran/48456
    * trans-array.c (get_std_lbound): For derived type variables
    return array valued component lbound.

2011-04-12  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/48360
    PR fortran/48456
    * gfortran.dg/realloc_on_assign_6.f03: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/realloc_on_assign_6.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/48360] [4.6/4.7 Regression] ICE on array assignment statement with allocatable LHS
  2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
                   ` (6 preceding siblings ...)
  2011-04-12 19:15 ` pault at gcc dot gnu.org
@ 2011-04-13 18:38 ` pault at gcc dot gnu.org
  2011-04-13 19:20 ` pault at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2011-04-13 18:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> 2011-04-13 18:38:21 UTC ---
Author: pault
Date: Wed Apr 13 18:38:17 2011
New Revision: 172390

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172390
Log:
2011-04-13  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/48360
    PR fortran/48456
    * trans-array.c (get_std_lbound): For derived type variables
    return array valued component lbound.

2011-04-13  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/48360
    PR fortran/48456
    * gfortran.dg/realloc_on_assign_6.f03: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/realloc_on_assign_6.f03
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/trans-array.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/48360] [4.6/4.7 Regression] ICE on array assignment statement with allocatable LHS
  2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
                   ` (7 preceding siblings ...)
  2011-04-13 18:38 ` pault at gcc dot gnu.org
@ 2011-04-13 19:20 ` pault at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2011-04-13 19:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> 2011-04-13 19:20:12 UTC ---
Fixed on trunk and 4.6.

Thanks for the report

Paul


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

end of thread, other threads:[~2011-04-13 19:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-30 11:20 [Bug fortran/48360] New: ICE on array assignment statement with allocatable LHS krefson at googlemail dot com
2011-03-30 12:39 ` [Bug fortran/48360] [4.6/4.7 Regression] " burnus at gcc dot gnu.org
2011-03-31 10:39 ` jakub at gcc dot gnu.org
2011-03-31 13:25 ` jvdelisle at gcc dot gnu.org
2011-03-31 13:37 ` jvdelisle at gcc dot gnu.org
2011-04-01 17:54 ` jvdelisle at gcc dot gnu.org
2011-04-08  4:17 ` pault at gcc dot gnu.org
2011-04-12 19:15 ` pault at gcc dot gnu.org
2011-04-13 18:38 ` pault at gcc dot gnu.org
2011-04-13 19:20 ` 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).