Bug 29321 - [4.1/4.2 Regression] optional arguments+derived types = segmentation fault
Summary: [4.1/4.2 Regression] optional arguments+derived types = segmentation fault
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.1.2
Assignee: Paul Thomas
URL:
Keywords: ice-on-valid-code
Depends on: 29284
Blocks:
  Show dependency treegraph
 
Reported: 2006-10-02 12:53 UTC by Olav Vahtras
Modified: 2006-10-03 20:15 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-03 11:11:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olav Vahtras 2006-10-02 12:53:24 UTC
	
Compilation of functions/subroutines with optional derived type arguments 
gives segmentation fault. 

a.F90: In function 'func':
a.F90:11: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

If I remove one of the optional arguments (C in SUB)
in the sample code below it appears to work

Environment:
System: Linux olavs 2.6.8-2-686 #1 Thu May 19 17:53:30 JST 2005 i686 GNU/Linux
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../gcc/configure --prefix=/cosmic/coudert/tmp/gfortran-20060906/irun --enable-languages=c,fortran --host=i386-linux --with-gmp=/cosmic/coudert/tmp/gfortran-20060906/gfortran_libs

How-To-Repeat:
	
MODULE MYINT
   TYPE NUM
      INTEGER :: R = 0
   END TYPE NUM
   CONTAINS 
      FUNCTION FUNC(A,B) RESULT(E)
      IMPLICIT NONE
      TYPE(NUM)  A,B,E
      INTENT(IN) ::  A,B
      OPTIONAL B
      E%R=A%R
      CALL SUB(A,E)
      END FUNCTION FUNC

      SUBROUTINE SUB(A,E,B,C)
      IMPLICIT NONE
      TYPE(NUM) A,E,B,C
      INTENT(IN)   A,B
      INTENT(OUT)  E,C
      OPTIONAL B,C
      E%R=A%R
      END SUBROUTINE SUB
END MODULE MYINT
Comment 1 Andrew Pinski 2006-10-02 17:04:39 UTC
Confirmed, a regression. Looks related to PR 29284.
Comment 2 Paul Thomas 2006-10-03 11:11:39 UTC
I submitted a fix for this today.

Paul
Comment 3 Paul Thomas 2006-10-03 20:13:21 UTC
Subject: Bug 29321

Author: pault
Date: Tue Oct  3 20:13:03 2006
New Revision: 117413

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117413
Log:
2006-10-03  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29284
	PR fortran/29321
	PR fortran/29322
	* trans-expr.c (gfc_conv_function_call): Check the expression
	and the formal symbol are present when testing the actual
	argument.

	PR fortran/25091
	PR fortran/25092
	* resolve.c (resolve_entries): It is an error if the entries
	of an array-valued function do not have the same shape.

2006-10-03  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29284
	* gfortran.dg/optional_assumed_charlen_1.f90: New test.

	PR fortran/29321
	PR fortran/29322
	* gfortran.dg/missing_optional_dummy_2.f90: New test.

	PR fortran/25091
	PR fortran/25092
	* gfortran.dg/entry_array_specs_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/entry_array_specs_1.f90
    trunk/gcc/testsuite/gfortran.dg/missing_optional_dummy_2.f90
    trunk/gcc/testsuite/gfortran.dg/optional_assumed_charlen_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Paul Thomas 2006-10-03 20:15:10 UTC
Fixed on trunk

Paul
Comment 5 Francois-Xavier Coudert 2006-10-24 08:06:22 UTC
Subject: Bug 29321

Author: fxcoudert
Date: Tue Oct 24 08:05:55 2006
New Revision: 117996

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117996
Log:
A bunch of backports:

	PR fortran/29284
	PR fortran/29321
	PR fortran/29322
	* trans-expr.c (gfc_conv_function_call): Check the expression
	and the formal symbol are present when testing the actual
	argument.

	PR fortran/25091
	PR fortran/25092
	* resolve.c (resolve_entries): It is an error if the entries
	of an array-valued function do not have the same shape.

	PR fortran/29284
	* gfortran.dg/optional_assumed_charlen_1.f90: New test.

	PR fortran/29321
	PR fortran/29322
	* gfortran.dg/missing_optional_dummy_2.f90: New test.

	PR fortran/25091
	PR fortran/25092
	* gfortran.dg/entry_array_specs_1.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/entry_array_specs_1.f90
      - copied unchanged from r117413, trunk/gcc/testsuite/gfortran.dg/entry_array_specs_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/missing_optional_dummy_2.f90
      - copied unchanged from r117413, trunk/gcc/testsuite/gfortran.dg/missing_optional_dummy_2.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/optional_assumed_charlen_1.f90
      - copied unchanged from r117413, trunk/gcc/testsuite/gfortran.dg/optional_assumed_charlen_1.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog