Bug 51870 - [OOP] ICE with ALLOCATE and SOURCE-expr function returning BT_CLASS
Summary: [OOP] ICE with ALLOCATE and SOURCE-expr function returning BT_CLASS
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2012-01-16 15:51 UTC by Tobias Burnus
Modified: 2012-01-27 10:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2012-01-16 15:51:44 UTC
When compiling the following program, one gets:

main.F90: In function ‘MAIN__’:
main.F90:23:0: internal compiler error: in fold_convert_loc, at fold-const.c:1894

While compiling with crayftn gives no error.


Backtrace:
#0  fold_convert_loc (loc=0, type=0x2aaaace2c7e0, arg=<optimized out>)
    at gcc/fold-const.c:1894
#1  0x00000000005a5800 in gfc_allocate_allocatable (block=0x7fffffffd800,
            mem=0x2aaaacf262d8, size=0x2aaaacf26310, token=0x0,
            status=0x0, errmsg=0x0, errlen=0x0, label_finish=0x0, expr=0x16e8f10)
    at gcc/fortran/trans.c:749
#2  0x000000000060092f in gfc_trans_allocate (code=<optimized out>)
    at gcc/fortran/trans-stmt.c:4918

The failing assert is:

1893    gcc_assert (TREE_CODE (orig) == VECTOR_TYPE
1894                && tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig)));


module show_producer_class
  implicit none
  type integrand
  end type integrand

  type show_producer
  contains
    procedure ,nopass :: create_show
  end type
contains
  function create_show() result(new_integrand)
    class(integrand) ,allocatable :: new_integrand
    allocate(new_integrand)
  end function
end module

program main
  use show_producer_class
  implicit none
  class(integrand) ,allocatable :: kernel
  type(show_producer) :: executive_producer

  allocate(kernel,source=executive_producer%create_show() )
end program
Comment 1 Paul Thomas 2012-01-27 10:06:04 UTC
Author: pault
Date: Fri Jan 27 10:05:56 2012
New Revision: 183613

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183613
Log:
2012-01-27  Paul Thomas  <pault@gcc.gnu.org>
	    Tobias Burnus <burnus@gcc.gnu.org>

	PR fortran/48705
	PR fortran/51870
	PR fortran/51943
	PR fortran/51946
	* trans-array.c (gfc_array_init_size): Add two extra arguments
	to convey the dynamic element size of a calls object and to
	return the number of elements that have been allocated.
	(gfc_array_allocate): Add the same arguments and use them to
	call gfc_array_init_size.  Before the allocation dereference
	the data pointer, if necessary. Set the allocated array to zero
	if the class element size or expr3 are non-null.
	* trans-expr.c (gfc_conv_class_to_class): Give this function
	global scope.
	(get_class_array_ref): New function.
	(gfc_copy_class_to_class): New function.
	* trans-array.h : Update prototype for gfc_array_allocate.
	* trans-stmt.c (gfc_trans_allocate): For non-variable class
	STATUS expressions extract the class object and the dynamic
	element size. Use the latter to call gfc_array_allocate and
	the former for setting the vptr and, via
	gfc_copy_class_to_clasfc_cs, to copy to the allocated data.
	* trans.h : Prototypes for gfc_get_class_array_ref,
	gfc_copy_class_to_class and gfc_conv_class_to_class.
  

2012-01-27  Paul Thomas  <pault@gcc.gnu.org>
	    Tobias Burnus <burnus@gcc.gnu.org>

	PR fortran/48705
	* gfortran.dg/class_allocate_11.f03: New.

	PR fortran/51870
	PR fortran/51943
	PR fortran/51946
	* gfortran.dg/class_allocate_7.f03: New.
	* gfortran.dg/class_allocate_8.f03: New.
	* gfortran.dg/class_allocate_9.f03: New.
	* gfortran.dg/class_allocate_10.f03: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/class_allocate_10.f03
    trunk/gcc/testsuite/gfortran.dg/class_allocate_11.f03
    trunk/gcc/testsuite/gfortran.dg/class_allocate_7.f03
    trunk/gcc/testsuite/gfortran.dg/class_allocate_8.f03
    trunk/gcc/testsuite/gfortran.dg/class_allocate_9.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-array.h
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/fortran/trans.h
    trunk/gcc/testsuite/ChangeLog
Comment 2 Paul Thomas 2012-01-27 10:15:08 UTC
Fixed on trunk

Thanks for the report

Paul