Bug 34008

Summary: ICE in gfc_trans_call, at fortran/trans-stmt.c:389 on elemental assignment
Product: gcc Reporter: Harald Anlauf <anlauf>
Component: fortranAssignee: Paul Thomas <pault>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P3    
Version: 4.3.0   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2007-11-07 14:39:48
Bug Depends on:    
Bug Blocks: 32834    
Attachments: Demo code

Description Harald Anlauf 2007-11-06 22:19:40 UTC
Hi,

there's a bug that shows up when overloading elemental assignments.
The attached code sample crashes with:

gfcbug74.f90: In function 'assign_atm_to_atm':
gfcbug74.f90:33: internal compiler error: in gfc_trans_call, at fortran/trans-stmt.c:389

When replacing the offending line

    y% m = x% m                             ! ICE

by an explicit loop

    do i=1,42; y% m(i) = x% m(i); end do    ! Works

the code compiles.

Cheers,
-ha
Comment 1 Harald Anlauf 2007-11-06 22:20:29 UTC
Created attachment 14491 [details]
Demo code
Comment 2 Paul Thomas 2007-11-07 14:39:47 UTC
According to

12.3.2.1.2 Defined assignments
If ASSIGNMENT is specified in an INTERFACE statement, all the procedures in the interface block shall be subroutines that may be referenced as defined assignments (7.5.1.3). Each of these subroutines shall have exactly two dummy arguments. Each argument shall be nonoptional. The first argument shall have INTENT (OUT) or INTENT (INOUT).........

gfortran is asserting INTENT (OUT) and not allowing INOUT.

I'll fix it this weekend.

Paul

PS This is the fix:

Index: /svn/trunk/gcc/fortran/trans-stmt.c
===================================================================
*** /svn/trunk/gcc/fortran/trans-stmt.c (revision 129882)
--- /svn/trunk/gcc/fortran/trans-stmt.c (working copy)
*************** gfc_trans_call (gfc_code * code, bool de
*** 386,392 ****
        {
          gfc_symbol *sym;
          sym = code->resolved_sym;
!         gcc_assert (sym->formal->sym->attr.intent == INTENT_OUT);
          gcc_assert (sym->formal->next->sym->attr.intent == INTENT_IN);
          gfc_conv_elemental_dependencies (&se, &loopse, sym,
                                           code->ext.actual);
--- 386,393 ----
        {
          gfc_symbol *sym;
          sym = code->resolved_sym;
!         gcc_assert (sym->formal->sym->attr.intent == INTENT_OUT
!                       || sym->formal->sym->attr.intent == INTENT_INOUT);
          gcc_assert (sym->formal->next->sym->attr.intent == INTENT_IN);
          gfc_conv_elemental_dependencies (&se, &loopse, sym,
                                           code->ext.actual);

It might be better to remove the assertions and replace them with errors in resolve.c

Comment 3 Dominique d'Humieres 2007-11-13 08:52:44 UTC
The patch works as advertised without regression on both PPC and Intel Darwin8.
Comment 4 patchapp@dberlin.org 2007-11-14 07:03:20 UTC
Subject: Bug number PR34008

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00769.html
Comment 5 Paul Thomas 2007-11-16 14:47:42 UTC
Subject: Bug 34008

Author: pault
Date: Fri Nov 16 14:47:31 2007
New Revision: 130232

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130232
Log:
2007-11-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34008
	* trans-stmt.c (gfc_conv_elemental_dependencies): Add check for
	INTENT_INOUT as well as INTENT_OUT.
	(gfc_trans_call): Remove redundant gcc_asserts in dependency
	check.

2007-11-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34008
	* gfortran.dg/interface_assignment_3.f90.

Added:
    trunk/gcc/testsuite/gfortran.dg/interface_assignment_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Paul Thomas 2007-11-16 14:49:35 UTC
Fixed on trunk

Paul