[Patch, fortran] PR96624 - A segment fault occurred when using the reshape function result to assign a variable

Paul Richard Thomas paul.richard.thomas@gmail.com
Thu Aug 27 06:17:41 GMT 2020


Hi All,

Here is another of Steve Kargl's patches.

Before the patch is applied, the following code is generated:
    atmp.0.span = 4;
    atmp.0.data = 0B;
    atmp.0.offset = 0;
    (*(integer(kind=4)[0] * restrict) atmp.0.data)[0] = 1;
    (*(integer(kind=4)[0] * restrict) atmp.0.data)[1] = 2;

which causes a segfault at run time. The test case counts the number of
occurrences of 'data' to check that the bad assignments have gone.

Regtests OK on FC31/x86_64 - OK for aster?

This patch fixes PR96624.

2020-08-27  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/96624
* simplify.c (gfc_simplify_reshape): Detect zero shape and
clear index if found.

gcc/testsuite/
PR fortran/96624
* gfortran.dg/reshape_8.f90 : New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit.diff
Type: text/x-patch
Size: 1172 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200827/98d0ad49/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr96624.f90
Type: text/x-fortran
Size: 411 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200827/98d0ad49/attachment-0001.bin>


More information about the Gcc-patches mailing list