Ping! Updated patch with the comments gotten so far. Ok for trunk? - Andre On Fri, 2 Sep 2016 09:59:19 +0200 Andre Vehreschild wrote: > Hi all, > > attached patch fixes the issue raised by PR72832. The issue was that > the array descriptor of the SOURCE= in an ALLOCATE () was used to > allocate an array object although an explicit array spec had been > given. > > The initial test showed a second issue when a class array was copied. > Compiling the code with -fcheck=bounds showed that no boundary check > was generated for class array copying using gfc_copy_class_to_class(). > I have added the generation of a runtime boundary check when the > -fcheck=bounds flag is set to locate the current issue. The test > allocate_with_source_23 is compiled with fcheck=bounds and fails as > expected ({ xfail *-*-* } set). > > Fixing the both issues unfortunately raised the next one, when trying > to get the size of a class array returned from a function (testcase: > allocate_with_source_11.f08). Here the issue was that for functions > returning class arrays gfc_conv_expr_descriptor () relied on the > descriptor being magicked into the scalarizer, which did not work in > this use case. Due to the first issue this bug did not raise beforehand. > Because I could not figure how to do it right in > gfc_conv_expr_descriptor (), I found a way to circumvent the issue by > getting the reference of the result of the function returning a class > array and massaging it to be ok for size (). This works quite neatly, > but may be someone with better knowledge of conv_expr_descriptor and > the scalarizer might want to fix it there. I suppose there are more > locations in the code, that work around this issue. > > Bootstrapped and regtests ok on x86_64-linux-gnu/F23 for trunk and > gcc-6. Ok for both? > > - Andre -- Andre Vehreschild * Email: vehre ad gmx dot de