Hi, this patch triggers assert in tree-inline that verify that array type and its main variant have same size (as pointer). In this case we have two types that do have same size, but the expression is different. It is created in both cases by layout_type becuase C++ FE calls layout_type before linking the variants. I think it is safe to move the call and avoid the duplication.
Bootstrapped/regtested x86_64-linux, OK? Honza PR tree-optimization/62053 * g++.dg/torture/pr62053.C: New testcase. * tree.c: Avoid ordering issue with layout_type. Index: testsuite/g++.dg/torture/pr62053.C =================================================================== --- testsuite/g++.dg/torture/pr62053.C (revision 0) +++ testsuite/g++.dg/torture/pr62053.C (revision 0) @@ -0,0 +1,7 @@ +// { dg-do compile } +typedef int GType; +class YGTable +{ + YGTable () { GType a[m_fn1 ()]; } + int m_fn1 (); +}; Index: cp/tree.c =================================================================== --- cp/tree.c (revision 216145) +++ cp/tree.c (working copy) @@ -863,12 +863,12 @@ build_cplus_array_type (tree elt_type, t { t = build_min_array_type (elt_type, index_type); set_array_type_canon (t, elt_type, index_type); - if (!dependent) - layout_type (t); TYPE_MAIN_VARIANT (t) = m; TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m); TYPE_NEXT_VARIANT (m) = t; + if (!dependent) + layout_type (t); } }