This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[PATCH] Fix unchecked union access in gfc_conv_array_parameter
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>
- Date: Sat, 29 Nov 2008 19:29:38 +0100
- Subject: [PATCH] Fix unchecked union access in gfc_conv_array_parameter
Hi,
the problem is responsible for almost all Fortran failures on SPARC64/Solaris:
http://gcc.gnu.org/ml/gcc-testresults/2008-11/msg02569.html
which are an assertion failure at the beginning of gfc_conv_array_parameter:
/* The symbol should have an array specification. */
gcc_assert (!sym || sym->as);
It turns out that the union access expr->ref->u just above is unchecked:
full_array_var = (expr->expr_type == EXPR_VARIABLE
&& expr->ref->u.ar.type == AR_FULL);
For example, on the func_derived_1.f90 test, expr->ref->u.ar.type is read
while expr->ref is a REF_COMPONENT so the resulting value is garbage and that
of full_array_var random.
Tested on SPARC/Solaris and SPARC64/Solaris, OK for mainline?
2008-11-29 Eric Botcazou <ebotcazou@adacore.com>
* trans-array.c (gfc_conv_array_parameter): Guard union access.
--
Eric Botcazou
Index: trans-array.c
===================================================================
--- trans-array.c (revision 142273)
+++ trans-array.c (working copy)
@@ -5206,7 +5206,8 @@ gfc_conv_array_parameter (gfc_se * se, g
stmtblock_t block;
full_array_var = (expr->expr_type == EXPR_VARIABLE
- && expr->ref->u.ar.type == AR_FULL);
+ && expr->ref->type == REF_ARRAY
+ && expr->ref->u.ar.type == AR_FULL);
sym = full_array_var ? expr->symtree->n.sym : NULL;
/* The symbol should have an array specification. */