[Bug fortran/19479] UBOUND causes ICE

craig dot powers at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Feb 8 09:17:00 GMT 2005


------- Additional Comments From craig dot powers at gmail dot com  2005-02-07 20:48 -------
The specific problem statement appears to be line 1799/1801 in gfc_simplify_bound:

    return gfc_copy_expr (as->upper[i-1]);

or

    return gfc_copy_expr (as->lower[i-1]);

The problematic execution sequence is (apologies for any errors due to only
fragmentary understanding of the data structures involved):
* as is initially set to array->as, where array is the expression sent to
gfc_simplify_bound; the symbol from array->symtree->n.sym is named as the
derived variable e.g. "tab" in the example.  This array spec is null (I presume
it's not the right place to get it).
* Because there are component references, the following loop walks them.
* The first reference is the COMPONENT reference (the name associated with
array->symtree->n.sym at this point is the derived type itself e.g.
"fft_tab_type" in the example code); it then attempts to take the array spec
from there.  Unfortunately, this spec is ALSO null.
* The second reference is the ARRAY reference; at this point it kicks out of the
walk loop because there's nothing following.
* The ref variable now points to a gfc_array_ref, and this is actually checked
by the code -- if ref->type is not REF_ARRAY or if ref->u.ar.type is not
AR_FULL, it kicks out of the routine with a NULL return value.
* At this point, as is still null; I presume that with the appropriate logic, it
could be taken from ref->u.ar, a simplistic fix like the following:
if (! as) as = ref->u.ar.as;
seems to fix the problem, with implications down the line unknown.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19479



More information about the Gcc-bugs mailing list