Commit 62227a69 by Thomas Koenig

re PR fortran/83540 (Invalid code with MATMUL, -fno-realloc-lhs -ffrontend-optimize)

2017-12-26  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/83540
	* frontend-passes.c (create_var): If an array to be created
	has unknown size and -fno-realloc-lhs is in effect,
	return NULL.

2017-12-26  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/83540
	* gfortran.dg/inline_matmul_20.f90: New test.

From-SVN: r256003
parent fa9d9dc2
2017-12-26 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/83540
* frontend-passes.c (create_var): If an array to be created
has unknown size and -fno-realloc-lhs is in effect,
return NULL.
2017-12-22 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
Eric Botcazou <ebotcazou@adacore.com>
......
......@@ -720,6 +720,11 @@ create_var (gfc_expr * e, const char *vname)
if (e->expr_type == EXPR_CONSTANT || is_fe_temp (e))
return gfc_copy_expr (e);
/* Creation of an array of unknown size requires realloc on assignment.
If that is not possible, just return NULL. */
if (flag_realloc_lhs == 0 && e->rank > 0 && e->shape == NULL)
return NULL;
ns = insert_block ();
if (vname)
......
2017-12-26 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/83540
* gfortran.dg/inline_matmul_20.f90: New test.
2017-12-26 Tom de Vries <tom@codesourcery.com>
* c-c++-common/unroll-5.c: Use relative line number.
......
! { dg-do run }
! { dg-additional-options "-fno-realloc-lhs -ffrontend-optimize" }
! This used to segfault at runtime.
! Original test case by Harald Anlauf.
program gfcbug142
implicit none
real, allocatable :: b(:,:)
integer :: n = 5
character(len=20) :: line
allocate (b(n,n))
call random_number (b)
write (unit=line,fmt='(2I5)') shape (matmul (b, transpose (b)))
if (line /= ' 5 5') call abort
end program gfcbug142
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment