[Bug fortran/72832] [OOP] ALLOCATE with SOURCE fails to allocate requested dimensions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72832 --- Comment #5 from Daan van Vugt --- Thanks for the quick responses. Just out of interest: what is the recommended way to allocate a class(t) variable of the same type as a but different size? Do I need to select type and list all of the types? that would be inconvenient.
[Bug fortran/72832] [OOP] ALLOCATE with SOURCE fails to allocate requested dimensions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72832 --- Comment #4 from Dominique d'Humieres --- For the record, the following test program allocate_source type :: t end type t type, extends(t) :: tt end type tt type(t), allocatable, dimension(:) :: a, b allocate(a(1:2)) write(*,*) size(a,1) allocate(b(1:4), source=a) write(*,*) size(b,1) end program allocate_source gives the "expected" output and at runtime the error 2 At line 11 of file pr72832_db_1.f90 Fortran runtime error: Array bound mismatch for dimension 1 of array 'b' (4/2) when compiled with -fcheck=bounds.
[Bug fortran/72832] [OOP] ALLOCATE with SOURCE fails to allocate requested dimensions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72832 --- Comment #3 from vehre at gcc dot gnu.org --- This patch fragment fixes the first issue: diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 5884e7a..8e5428a 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -5485,7 +5485,8 @@ gfc_trans_allocate (gfc_code * code) desc = tmp; tmp = gfc_class_data_get (tmp); } - e3_is = E3_DESC; + if (code->ext.alloc.arr_spec_from_expr3) + e3_is = E3_DESC; } else desc = !is_coarray ? se.expr
[Bug fortran/72832] [OOP] ALLOCATE with SOURCE fails to allocate requested dimensions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72832 vehre at gcc dot gnu.org changed: What|Removed |Added CC||vehre at gcc dot gnu.org --- Comment #2 from vehre at gcc dot gnu.org --- There are two bugs in one here: - the shape is selected from source= and not from the b(1:4), and - the shape of a and new b is not conformable, which can only be deduced at runtime (and is already when the class(t) is replaced by type(t) and -fcheck=all is used).
[Bug fortran/72832] [OOP] ALLOCATE with SOURCE fails to allocate requested dimensions
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72832 Dominique d'Humieres changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed||2016-08-08 Ever confirmed|0 |1 --- Comment #1 from Dominique d'Humieres --- > While I expect the second line to be 4. From the standard "If SOURCE= appears, source-expr shall be conformable with allocation." I think the code is invalid.