Bug 18689 - Internal compiler error with character pointer association in module subroutine
Summary: Internal compiler error with character pointer association in module subroutine
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: Fortran_character
  Show dependency treegraph
 
Reported: 2004-11-27 14:06 UTC by Paul Thomas
Modified: 2005-06-05 22:51 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-11-27 15:14:28


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Thomas 2004-11-27 14:06:10 UTC
!Extracted from linked data demo in appendix G
!
! (c) Copyright Michael Metcalf and John Reid, 1992. This file may be
! freely used and copied for educational purposes provided this notice
! remains attached. Extracted from "Fortran 90 Explained" Oxford
! University Press (Oxford and New York), ISBN 0-19-853772-7.
!
MODULE bug
   character(4), allocatable, target :: names(:)
CONTAINS
  SUBROUTINE bugeye(pnames)
    character(4), pointer                      :: pnames(:)
    allocate (names(10))
    pnames => names
  end subroutine bugeye
end module bug
program bug_demo
  use bug
end program bug_demo

$ /gcc-4.0/bin/gfortran -O3 bug_demo.f90 -o bug_demo
bug_demo.f90: In function 'bugeye':
bug_demo.f90:16: internal compiler error: in gfc_add_modify_expr, 
at /fortran/tr
ans.c:154
Please submit a full bug report,
Comment 1 Andrew Pinski 2004-11-27 15:14:28 UTC
Confirmed.
Comment 2 Andrew Pinski 2005-05-01 14:19:58 UTC
Fixed for 4.0.0.
Comment 3 Paul Thomas 2005-05-01 15:11:36 UTC
Subject: Re:  Internal compiler error with character pointer association in module subroutine

Andrew,

I have taken my eye off the ball, after my most recent cock-up; when did 
this get fixed?  I have searched for something related to PR18689 but have 
not found it - has this benefitted from fall-out from something else?  If 
so, a wee test case should be prepared.

Paul T 


Comment 4 Andrew Pinski 2005-05-01 15:15:43 UTC
Woops, this is not fixed, I must have used the wrong file to test with.
Comment 5 Paul Thomas 2005-05-01 15:17:07 UTC
Subject: Re:  Internal compiler error with character pointer association in module subroutine

In fact, how come it is fixed in 4.0 and not in 4.1?  I get the error still 
with yesterday's cvs for any optmisation.  I did not think that was 
possible?

Paul T 


Comment 6 GCC Commits 2005-05-29 16:02:36 UTC
Subject: Bug 18689

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pault@gcc.gnu.org	2005-05-29 16:02:11

Modified files:
	gcc/fortran    : trans-array.c trans-expr.c 

Log message:
	2005-05-29 Paul Thomas  <pault@gcc.gnu.org>
	
	PR fortran/16939
	PR fortran/17192
	PR fortran/17193
	PR fortran/17202
	PR fortran/18689
	PR fortran/18890
	PR fortran/21297
	* fortran/trans-array.c (gfc_conv_resolve_dependencies): Add string
	length to temp_ss for character pointer array assignments.
	* fortran/trans-expr.c (gfc_conv_variable): Correct errors in
	dereferencing of characters and character pointers.
	* fortran/trans-expr.c (gfc_conv_function_call): Provide string
	length as return argument for various kinds of handling of return.
	Return a char[]* temporary for character pointer functions and
	dereference the temporary upon return.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-array.c.diff?cvsroot=gcc&r1=1.45&r2=1.46
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-expr.c.diff?cvsroot=gcc&r1=1.44&r2=1.45

Comment 7 GCC Commits 2005-06-05 08:59:41 UTC
Subject: Bug 18689

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	pault@gcc.gnu.org	2005-06-05 08:59:18

Modified files:
	gcc/fortran    : ChangeLog trans-array.c trans-expr.c 

Log message:
	005-05-31  Paul Thomas  <pault@gcc.gnu.org>
	
	PR fortran/18109
	PR fortran/18283
	PR fortran/19107
	PR fortran/16939
	PR fortran/17192
	PR fortran/17193
	PR fortran/17202
	PR fortran/18689
	PR fortran/18890
	* fortran/trans-array.c (gfc_conv_expr_descriptor): Obtain the
	string length from the expression typespec character length value
	and set temp_ss->stringlength and backend_decl. Obtain the
	tree expression from gfc_conv_expr rather than gfc_conv_expr_val.
	Dereference the expression to obtain the character.
	* fortran/trans-array.c (gfc_conv_resolve_dependencies): Add string
	length to temp_ss for character pointer array assignments.
	* fortran/trans-expr.c (gfc_conv_component_ref): Remove the
	dereference of scalar character pointer structure components.
	* fortran/trans-expr.c (gfc_trans_subarray_assign): Obtain the
	string length for the structure component from the component
	expression.
	* fortran/trans-expr.c (gfc_conv_variable): Correct errors in
	dereferencing of characters and character pointers.
	* fortran/trans-expr.c (gfc_conv_function_call): Provide string
	length as return argument for various kinds of handling of return.
	Return a char[]* temporary for character pointer functions and
	dereference the temporary upon return.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.335.2.66&r2=1.335.2.67
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-array.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.39.2.3&r2=1.39.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-expr.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.38.2.4&r2=1.38.2.5

Comment 8 Paul Thomas 2005-06-05 22:46:28 UTC
Fixed in 4.0 and 4.1