[PATCH] PR fortran/99205 - [10/11 Regression] Out of memory with undefined character length

Harald Anlauf anlauf@gmx.de
Wed Mar 10 21:26:38 GMT 2021


Dear Tobias, all,

> The reason that it is not permitted is the "automatic data object"
> (see *...* highlighted parts in the quote):
>
> C876   (R839) A *variable* whose *designator* appears as a
> *data-stmt-object* or a data-i-do-object hall not be a
> dummy argument, accessed by use or host association,
> in a named common block unless the DATA statement is
> in a block data program unit, in blank common, a function name,
> a function result name, an *automatic* *data* *object,*
> or an allocatable variable.
>
> With the definition: "3.11 automatic data object
> nondummy data object with a type parameter or array bound that
> depends on the value of aspecification-expr that is not
> a constant expression (8.3)"

inspired by Tobias' (although invalid) code example I found another
testcase which lead to trouble during error recovery due to a NULL
pointer dereference.  Here's the updated changelog for the updated
patch (attached).  I also renamed the first testcase so that they
fit better to the existing scheme.

Again regtested on x86_64-pc-linux-gnu.  Now OK for mainline / 10?

Thanks,
Harald


PR fortran/99205 - Out of memory with undefined character length

A character variable appearing as a data statement object cannot
be automatic, thus it shall have constant length.

gcc/fortran/ChangeLog:

	PR fortran/99205
	* data.c (gfc_assign_data_value): Reject non-constant character
	length for lvalue.
	* trans-array.c (gfc_conv_array_initializer): Restrict loop to
	elements which are defined to avoid NULL pointer dereference.

gcc/testsuite/ChangeLog:

	PR fortran/99205
	* gfortran.dg/data_char_4.f90: New test.
	* gfortran.dg/data_char_5.f90: New test.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr99205.patch-v2
Type: application/octet-stream
Size: 2286 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210310/14b7a2f3/attachment.obj>


More information about the Gcc-patches mailing list