Bug 18769 - ICE in gfc_conv_array_initializer with array initialization with transfer
Summary: ICE in gfc_conv_array_initializer with array initialization with transfer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.3.0
Assignee: Brooks Moses
URL:
Keywords: ice-on-valid-code
Depends on: 17298
Blocks: 31237 19282 30881 31216
  Show dependency treegraph
 
Reported: 2004-12-01 22:27 UTC by Harald Anlauf
Modified: 2007-05-26 03:07 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-27 20:54:07


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Anlauf 2004-12-01 22:27:01 UTC
Hi,

the following code crashes gfortran:

program gfcbug21
  implicit none
  type t
     integer :: i
  end type t
  type (t), parameter :: u = t (1)
  integer,  parameter :: idx_list(1) = (/ 1 /)
  ! gfortran dies here:
  integer             :: j(1) = transfer (u,  idx_list)
  print *, j
end program gfcbug21

I get:

gfcbug21.f90: In function 'MAIN__':
gfcbug21.f90:10: internal compiler error: in gfc_conv_array_initializer, at 
fortran/trans-array.c:2946

(For the record: this works with Intel's ifc 7.1 but crashes ifort 8.1)

Cheers,
-ha
Comment 1 Andrew Pinski 2004-12-01 23:24:42 UTC
Confirmed.  Maybe related to PR15975.
Comment 2 Andrew Pinski 2005-05-01 14:17:32 UTC
Fixed for 4.0.0. 
Comment 3 Andrew Pinski 2005-05-01 15:18:34 UTC
Woops I must have used the wrong file to test with.
Comment 4 Andrew Pinski 2006-01-02 03:50:43 UTC
Related to PR 17298.
Comment 5 Andrew Pinski 2006-01-09 23:15:33 UTC
The problem here is that we did not reduce transfer to a constant.

Hmm, the problem is fully transfer which is why this fully related to PR 17298.

Looks like we don't currently handle transfer that well.
Comment 6 Andrew Pinski 2006-01-27 20:54:06 UTC
transfer could be converted over to use VIEW_CONVERT_EXPR of the constant but then again this is in non trans part of the fortran front-end.
Comment 7 Paul Thomas 2006-06-18 19:43:23 UTC
Harald,

The date at which you submitted this is an insult to my sensibilities; I hope that you appreciate the progress that we have made elsewhere and forgive us slowness in responding to this?  That said, I have been trying to bring initializers up the the 19th century, at least, and TRANSFER is the only missing transformational function. So, I will do what a man has to do and will square up the the grind of writing gfc_simplify_transfer.  I might be a little while.....

Paul
Comment 8 Paul Thomas 2006-06-20 04:31:12 UTC
Subject: Bug 18769

Author: pault
Date: Tue Jun 20 04:30:48 2006
New Revision: 114802

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

	PR fortran/25049
	PR fortran/25050
	* check.c (non_init_transformational): New function.
	(find_substring_ref): New function to signal use of disallowed
	transformational intrinsic in an initialization expression.
	(gfc_check_all_any): Call previous if initialization expr.
	(gfc_check_count): The same.
	(gfc_check_cshift): The same.
	(gfc_check_dot_product): The same.
	(gfc_check_eoshift): The same.
	(gfc_check_minloc_maxloc): The same.
	(gfc_check_minval_maxval): The same.
	(gfc_check_gfc_check_product_sum): The same.
	(gfc_check_pack): The same.
	(gfc_check_spread): The same.
	(gfc_check_transpose): The same.
	(gfc_check_unpack): The same.

	PR fortran/18769
	*intrinsic.c (add_functions): Add gfc_simplify_transfer.
	*intrinsic.h : Add prototype for gfc_simplify_transfer.
	*simplify.c (gfc_simplify_transfer) : New function to act as
	placeholder for eventual implementation.  Emit error for now.

	PR fortran/16206
	* expr.c (find_array_element): Eliminate condition on length of
	offset. Add bounds checking. Rearrange exit. Return try and
	put gfc_constructor result as an argument.
	(find_array_section): New function.
	(find_substring_ref): New function.
	(simplify_const_ref): Add calls to previous.
	(simplify_parameter_variable): Return on NULL expr.
	(gfc_simplify_expr): Only call gfc_expand_constructor for full
	arrays.

	PR fortran/20876
	* match.c (gfc_match_forall): Add missing locus to gfc_code.

2006-06-20  Paul Thomas  <pault@gcc.gnu.org>

	PR libfortran/28005
	* m4/matmul.m4: aystride = 1 does not uniquely detect the
	presence of a temporary transpose; an array element in the
	first dimension produces the same signature.  Detect this
	using the rank of a and add specific code.
	* generated/matmul_r4.c: Regenerate.
	* generated/matmul_r8.c: Regenerate.
	* generated/matmul_r10.c: Regenerate.
	* generated/matmul_r16.c: Regenerate.
	* generated/matmul_c4.c: Regenerate.
	* generated/matmul_c8.c: Regenerate.
	* generated/matmul_c10.c: Regenerate.
	* generated/matmul_c16.c: Regenerate.
	* generated/matmul_i4.c: Regenerate.
	* generated/matmul_i8.c: Regenerate.
	* generated/matmul_i16.c: Regenerate.

2006-06-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/16206
	* gfortran.dg/array_initializer_1.f90: New test.

	PR fortran/28005
	* gfortran.dg/matmul_3.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/array_initializer_1.f90
    trunk/gcc/testsuite/gfortran.dg/matmul_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/generated/matmul_c10.c
    trunk/libgfortran/generated/matmul_c16.c
    trunk/libgfortran/generated/matmul_c4.c
    trunk/libgfortran/generated/matmul_c8.c
    trunk/libgfortran/generated/matmul_i16.c
    trunk/libgfortran/generated/matmul_i4.c
    trunk/libgfortran/generated/matmul_i8.c
    trunk/libgfortran/generated/matmul_r10.c
    trunk/libgfortran/generated/matmul_r16.c
    trunk/libgfortran/generated/matmul_r4.c
    trunk/libgfortran/generated/matmul_r8.c
    trunk/libgfortran/m4/matmul.m4

Comment 9 Paul Thomas 2006-06-23 04:47:11 UTC
Subject: Bug 18769

Author: pault
Date: Fri Jun 23 04:46:50 2006
New Revision: 114925

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

	PR fortran/25049
	PR fortran/25050
	* check.c (non_init_transformational): New function.
	(find_substring_ref): New function to signal use of disallowed
	transformational intrinsic in an initialization expression.
	(gfc_check_all_any): Call previous if initialization expr.
	(gfc_check_count): The same.
	(gfc_check_cshift): The same.
	(gfc_check_dot_product): The same.
	(gfc_check_eoshift): The same.
	(gfc_check_minloc_maxloc): The same.
	(gfc_check_minval_maxval): The same.
	(gfc_check_gfc_check_product_sum): The same.
	(gfc_check_pack): The same.
	(gfc_check_spread): The same.
	(gfc_check_transpose): The same.
	(gfc_check_unpack): The same.

	PR fortran/18769
	*intrinsic.c (add_functions): Add gfc_simplify_transfer.
	*intrinsic.h : Add prototype for gfc_simplify_transfer.
	*simplify.c (gfc_simplify_transfer) : New function to act as
	placeholder for eventual implementation.  Emit error for now.

	PR fortran/16206
	* expr.c (find_array_element): Eliminate condition on length of
	offset. Add bounds checking. Rearrange exit. Return try and
	put gfc_constructor result as an argument.
	(find_array_section): New function.
	(find_substring_ref): New function.
	(simplify_const_ref): Add calls to previous.
	(simplify_parameter_variable): Return on NULL expr.
	(gfc_simplify_expr): Only call gfc_expand_constructor for full
	arrays.

	PR fortran/20876
	* match.c (gfc_match_forall): Add missing locus to gfc_code.

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

	PR fortran/16206
	* gfortran.dg/array_initializer_1.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/array_initializer_1.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/check.c
    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/intrinsic.h
    branches/gcc-4_1-branch/gcc/fortran/match.c
    branches/gcc-4_1-branch/gcc/fortran/simplify.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 10 Paul Thomas 2006-06-23 15:43:35 UTC
Now for the hard work of writing simplify_transfer!

Paul
Comment 11 patchapp@dberlin.org 2006-06-29 21:36:16 UTC
Subject: Bug number PR18769

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-06/msg00934.html
Comment 12 Jerry DeLisle 2006-10-14 15:38:40 UTC
Paul,  should this be closed?
Comment 13 Paul Thomas 2006-10-14 17:31:26 UTC
Jerry,

See comment #10.  The 'problem' is to take the gmp/mpfr representations of the values in the constructor expression, write them out to form the source, read then back in binary as the destination, convert the array into gmp/mpfr values and pop the values into a constructor array.

It is actually simple enough but tedious; with one thing or another I have not gotten round to it. One of the key points will be to get the numeric representation right, so bits will have to be borrowed from all over (arith.c? trans-xxx.c?) to get the gmp/mpfr to the gfc type+kind's and back again.  I was sort of hoping that Steve would take an interest because he is exceeding clued up on such matters. However, he and I both have been busy. *sigh*

If you want to be guided.... you would be very welcome.

Paul
Comment 14 Jerry DeLisle 2006-10-14 19:37:01 UTC
Oh, It was comment 11 that threw me off.  Thats why I asked.  Let me think about takingthis on before I do so.
Comment 15 Paul Thomas 2006-10-14 19:58:32 UTC
Jerry,

I was not entirely serious - if you want to take it on, great, but...  it's a pain in the beeehind!

Paul
Comment 16 Thomas Koenig 2007-01-08 07:45:29 UTC
I was just looking at the gfc_simplify_transfer function, and
it appears it isn't called for the original test program.
Any idea why?
Comment 17 Paul Thomas 2007-05-16 06:41:20 UTC
Subject: Bug 18769

Author: pault
Date: Wed May 16 05:40:51 2007
New Revision: 124759

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124759
Log:
2007-05-16  Brooks Moses  <brooks.moses@codesourcery.com>

	PR fortran/18769
	PR fortran/30881
	PR fortran/31194
	PR fortran/31216
	PR fortran/31427
	* target-memory.c: New file.
	* target-memory.h: New file.
	* simplify.c: Add #include "target-memory.h".
	(gfc_simplify_transfer): Implement constant-
	folding for TRANSFER intrinsic.
	* Make-lang.in: Add dependencies on new target-memory.* files.

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

	PR fortran/18769
	PR fortran/30881
	PR fortran/31194
	PR fortran/31216
	PR fortran/31427
	* transfer_simplify_1.f90: New test.
	* transfer_simplify_2.f90: New test.

Added:
    trunk/gcc/fortran/target-memory.c
    trunk/gcc/fortran/target-memory.h
    trunk/gcc/testsuite/gfortran.dg/transfer_simplify_1.f90
    trunk/gcc/testsuite/gfortran.dg/transfer_simplify_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/Make-lang.in
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog

Comment 18 Paul Thomas 2007-05-16 09:10:39 UTC
Fixed on trunk

Paul and Brooks