[Fortran, Patch, PR72832, v1] [6/7 Regression] [OOP] ALLOCATE with SOURCE fails to allocate requested dimensions

Andre Vehreschild vehre@gmx.de
Fri Sep 2 07:59:00 GMT 2016


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 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr72832_1.clog
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160902/75df40ab/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr72832_1.patch
Type: text/x-patch
Size: 6051 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160902/75df40ab/attachment.bin>


More information about the Gcc-patches mailing list