Hi! When I've added the VLA tweak for OpenMP to avoid error_mark_nodes in the IL in type, I forgot that TYPE_DOMAIN could be NULL. Furthermore, as an optimization, this patch checks the hopefully cheapest condition that is very likely false most of the time (enabled only during OpenMP handling) first.
Bootstrapped/regtested on x86_64-linux and i686-linux, acked by Richard in the PR, committed to trunk so far. 2020-04-17 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/94621 * tree-inline.c (remap_type_1): Don't dereference NULL TYPE_DOMAIN. Move id->adjust_array_error_bounds check first in the condition. * gcc.c-torture/compile/pr94621.c: New test. --- gcc/tree-inline.c.jj 2020-03-16 09:03:32.776171761 +0100 +++ gcc/tree-inline.c 2020-04-16 17:57:05.319059075 +0200 @@ -556,8 +556,9 @@ remap_type_1 (tree type, copy_body_data /* For array bounds where we have decided not to copy over the bounds variable which isn't used in OpenMP/OpenACC region, change them to an uninitialized VAR_DECL temporary. */ - if (TYPE_MAX_VALUE (TYPE_DOMAIN (new_tree)) == error_mark_node - && id->adjust_array_error_bounds + if (id->adjust_array_error_bounds + && TYPE_DOMAIN (new_tree) + && TYPE_MAX_VALUE (TYPE_DOMAIN (new_tree)) == error_mark_node && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != error_mark_node) { tree v = create_tmp_var (TREE_TYPE (TYPE_DOMAIN (new_tree))); --- gcc/testsuite/gcc.c-torture/compile/pr94621.c.jj 2020-04-16 17:54:48.924077393 +0200 +++ gcc/testsuite/gcc.c-torture/compile/pr94621.c 2020-04-16 17:54:33.774301572 +0200 @@ -0,0 +1,16 @@ +/* PR tree-optimization/94621 */ + +struct S { int c, e[]; }; + +static inline int +foo (struct S *m, int r, int c) +{ + int (*a)[][m->c] = (int (*)[][m->c])&m->e; + return (*a)[r][c]; +} + +void +bar (struct S *a) +{ + foo (a, 0, 0); +} Jakub