[pach, fortran] Fix PR 92961, ICE on division by zero error in array bounds

Thomas Koenig tkoenig@netcologne.de
Fri Dec 20 14:24:00 GMT 2019


Hello world,

the attached patch fixes an ICE in an array declaration where the
specified size came from 0/0. This is an 8/9/10 regression.

The actual ICE fix was the NULL check in simplify_intrinsic_op, which in
turn led to strange error messages, which are then corrected by
the rest of the patch. Rather than try to transport state across I
do not know how many levels of calls, I chose a global variable.

Regression-tested. OK for all affected branches?

Regards

	Thomas

2019-12-20  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/92961
	* gfortran.h (gfc_seen_div0): Add declaration.
	* arith.h (gfc_seen_div0): Add definition.
	(eval_intrinsic): For integer division by zero, issue
	gfc_error_now and set gfc_seen_div0.
	* decl.c (variable_decl): If a division by zero error has been
	seen previously, do not issue an addtional error.
	* expr.c (simplify_intrinsic_op): Return NULL if op1 is NULL.

2019-12-20  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/92961
	* gfortran.dg/arith_divide_2.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p2.diff
Type: text/x-patch
Size: 2686 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20191220/c2c8e8f6/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arith_divide_2.f90
Type: text/x-fortran
Size: 335 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20191220/c2c8e8f6/attachment-0001.bin>


More information about the Fortran mailing list