Bug 25597 - ICE with allocate on the return value of a function, character array with a len of an argument
Summary: ICE with allocate on the return value of a function, character array with a l...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: Fortran_character 25618
  Show dependency treegraph
 
Reported: 2005-12-29 18:01 UTC by krange
Modified: 2006-04-23 05:39 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-29 18:21:19


Attachments
self contained (but probably not minimal) source that triggers ICE (2.09 KB, text/plain)
2005-12-29 18:02 UTC, krange
Details

Note You need to log in before you can comment on or make changes to this bug.
Description krange 2005-12-29 18:01:24 UTC
rangek@krange:~/UMN_Projects/Software/Libraries/YorkLib_test> gfortran20051228 -v -save-temps -c -g bug.f95
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --program-suffix=20051228 --enable-languages=fortran
Thread model: posix
gcc version 4.2.0 20051228 (experimental)
 /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.2.0/f951 bug.f95 -quiet -dumpbase bug.f95 -mtune=k8 -auxbase bug -g -version -o bug.s
GNU F95 version 4.2.0 20051228 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.2.0 20051228 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
bug.f95: In function ‘reallocate_hnv’:
bug.f95:281: internal compiler error: in fold_binary, at fold-const.c:7198
Comment 1 krange 2005-12-29 18:02:40 UTC
Created attachment 10565 [details]
self contained (but probably not minimal) source that triggers ICE
Comment 2 Andrew Pinski 2005-12-29 18:13:44 UTC
Reduced testcase:
  FUNCTION reallocate_hnv(p,n,LEN)
    CHARACTER(LEN=LEN), DIMENSION(:), POINTER :: reallocate_hnv
    ALLOCATE(reallocate_hnv(n),stat=ierr)
  END FUNCTION reallocate_hnv
Comment 3 Andrew Pinski 2005-12-29 18:21:19 UTC
Confirmed, not a regression.
Comment 4 Andrew Pinski 2006-01-01 06:09:29 UTC
A little further reduced:
FUNCTION reallocate_hnv(p,n,LEN)
  CHARACTER(LEN=LEN),  POINTER :: reallocate_hnv
   ALLOCATE(reallocate_hnv)
END FUNCTION reallocate_hnv
Comment 5 Andrew Pinski 2006-01-01 06:27:48 UTC
(In reply to comment #4)
> A little further reduced:

Actually that is a different bug.

Anyways the reduced testcase looks like:
  FUNCTION reallocate_hnv(p,n,LEN)
    CHARACTER(LEN=LEN), DIMENSION(:), POINTER :: reallocate_hnv
    ALLOCATE(reallocate_hnv(n))
  END FUNCTION reallocate_hnv
Comment 6 Paul Thomas 2006-04-10 14:35:27 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > A little further reduced:
> Actually that is a different bug.
> Anyways the reduced testcase looks like:
>   FUNCTION reallocate_hnv(p,n,LEN)
>     CHARACTER(LEN=LEN), DIMENSION(:), POINTER :: reallocate_hnv
>     ALLOCATE(reallocate_hnv(n))
>   END FUNCTION reallocate_hnv

This no longer ICEs but does bomn out in runtime, as described in PR27096

Paul
Comment 7 patchapp@dberlin.org 2006-04-12 19:28:52 UTC
Subject: Bug number PR25597

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/2006-04/msg00350.html
Comment 8 Paul Thomas 2006-04-16 03:45:34 UTC
Subject: Bug 25597

Author: pault
Date: Sun Apr 16 03:45:24 2006
New Revision: 112981

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

	PR fortran/26822
	* intrinsic.c (add_functions): Mark LOGICAL as elemental.

	PR fortran/26787
	* expr.c (gfc_check_assign): Extend scope of error to include
	assignments to a procedure in the main program or, from a
	module or internal procedure that is not that represented by
	the lhs symbol. Use VARIABLE rather than l-value in message.

	PR fortran/27096
	* trans-array.c (gfc_trans_deferred_array): If the backend_decl
	is not a descriptor, dereference and then test and use the type.

	PR fortran/25597
	* trans-decl.c (gfc_trans_deferred_vars): Check if an array
	result, is also automatic character length.  If so, process
	the character length.

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* trans_intrinsic.c (gfc_walk_intrinsic_bound): Set
	data.info.dimen for bound intrinsics.
	* trans_array.c (gfc_conv_ss_startstride): Pick out LBOUND and
	UBOUND intrinsics and supply their shape information to the ss
	and the loop.

	PR fortran/27124
	* trans_expr.c (gfc_trans_function_call):  Add a new block, post,
	in to which all the argument post blocks are put.  Add this block
	to se->pre after a byref call or to se->post, otherwise.

2006-04-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/26787
	* gfortran.dg/proc_assign_1.f90: New test.
	* gfortran.dg/procedure_lvalue.f90: Change message.
	* gfortran.dg/namelist_4.f90: Add new error.

	PR fortran/27096
	* gfortran.dg/auto_pointer_array_result_1.f90

	PR fortran/27089
	* gfortran.dg/specification_type_resolution_1.f90

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* gfortran.dg/bounds_temporaries_1.f90: New test.

	PR fortran/27124
	* gfortran.dg/array_return_value_1.f90: New test.



Added:
    trunk/gcc/testsuite/gfortran.dg/array_return_value_1.f90
    trunk/gcc/testsuite/gfortran.dg/auto_char_pointer_array_result_1.f90
    trunk/gcc/testsuite/gfortran.dg/auto_pointer_array_result_1.f90
    trunk/gcc/testsuite/gfortran.dg/bounds_temporaries_1.f90
    trunk/gcc/testsuite/gfortran.dg/proc_assign_1.f90
    trunk/gcc/testsuite/gfortran.dg/specification_type_resolution_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/namelist_4.f90
    trunk/gcc/testsuite/gfortran.dg/procedure_lvalue.f90

Comment 9 Paul Thomas 2006-04-23 05:33:26 UTC
Subject: Bug 25597

Author: pault
Date: Sun Apr 23 05:33:16 2006
New Revision: 113191

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

	PR fortran/27122
	* resolve.c (resolve_function): Remove general restriction on auto
	character length function interfaces.
	(gfc_resolve_uops): Check restrictions on defined operator
	procedures.
	(resolve_types): Call the check for defined operators.

	PR fortran/27113
	* trans-array.c (get_array_ctor_var_strlen): Remove typo in enum.
	Part of the fix in 4.2, which does not work in 4.1 because the
	divergence is now too great.

	PR fortran/26822
	* intrinsic.c (add_functions): Mark LOGICAL as elemental.

	PR fortran/26787
	* expr.c (gfc_check_assign): Extend scope of error to include
	assignments to a procedure in the main program or, from a
	module or internal procedure that is not that represented by
	the lhs symbol. Use VARIABLE rather than l-value in message.

	PR fortran/25597
	* trans-decl.c (gfc_trans_deferred_vars): Check if an array
	result, is also automatic character length.  If so, process
	the character length. Note that this fixes the bug in 4.2
	but not here in 4.1 because the trees have diverged too much.
	Manifestly correct, so applied anyway.

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* trans_intrinsic.c (gfc_walk_intrinsic_bound): Set
	data.info.dimen for bound intrinsics.
	* trans_array.c (gfc_conv_ss_startstride): Pick out LBOUND and
	UBOUND intrinsics and supply their shape information to the ss
	and the loop.

	PR fortran/27124
	* trans_expr.c (gfc_trans_function_call):  Add a new block, post,
	in to which all the argument post blocks are put.  Add this block
	to se->pre after a byref call or to se->post, otherwise.

2006-04-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/27122
	* gfortran.dg/defined_operators_1.f90: New test.
	* gfortran.dg/assumed_charlen_function_1.f90: Add new error and
	remove old ones associated, incorrectly, with Note 5.46.

	PR fortran/26787
	* gfortran.dg/proc_assign_1.f90: New test.
	* gfortran.dg/procedure_lvalue.f90: Change message.
	* gfortran.dg/namelist_4.f90: Add new error.

	PR fortran/27089
	* gfortran.dg/specification_type_resolution_1.f90

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* gfortran.dg/bounds_temporaries_1.f90: New test.

	PR fortran/27124
	* gfortran.dg/array_return_value_1.f90: New test.



Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/array_return_value_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/bounds_temporaries_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/defined_operators_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/proc_assign_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/specification_type_resolution_1.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/expr.c
    branches/gcc-4_1-branch/gcc/fortran/intrinsic.c
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/trans-array.c
    branches/gcc-4_1-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_1-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_1-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/assumed_charlen_function_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/namelist_4.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/procedure_lvalue.f90

Comment 10 Paul Thomas 2006-04-23 05:39:24 UTC
Fixed on trunk but,sadly, not on 4.1 because divergences have become too great.

Paul