[PATCH] Fortran: fix PR103390, ICE in gimplification

Sandra Loosemore sandra@codesourcery.com
Sun Jan 2 18:32:17 GMT 2022


This patch is for PR103390.  For background on this issue, the Fortran 
standard requires that, when passing a non-contiguous array from Fortran 
to a BIND(C) function with the CONTIGUOUS attribute on the corresponding 
dummy argument, the compiler has to arrange for it to be copied to/from 
a contiguous temporary.  The ICE was happening because the front end was 
attempting to copy out to an array-valued expression that isn't an 
lvalue, and producing invalid code.

I poked around at several related examples (included as test cases in 
the patch) and realized that it should not be doing any copying at all 
here, since the expression result already was being put in a contiguous 
temporary.  And, besides the invalid code on copy-out, in some cases it 
was generating multiple copies of the code to compute the expression on 
copy-in.  :-S

Both parts of the patch seem to be necessary to fix all the test cases. 
Tobias pointed me in this direction when I discussed it with him a few 
weeks ago so I hope I got it right.

OK to check in?  It regression-tests fine on x86_64.

-Sandra
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr103390.patch
Type: text/x-patch
Size: 12398 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/fortran/attachments/20220102/5bf9dbd0/attachment.bin>


More information about the Fortran mailing list