https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97350
--- Comment #10 from Jan Hubicka <hubicka at gcc dot gnu.org> --- OK, I was poking a bit about the problem and indeed the bootstrapped gnat with -O3 and PGO ices, while gnat built normally does not. We fail: #2 0x00000000019b7dcb in _Z13variable_sizeP9tree_node (size=0x7ffff7448900) at ../../gcc/stor-layout.c:172 172 gcc_assert (self_refs.length () > 0); (gdb) l 167 if (TREE_CODE (t) == CALL_EXPR || self_referential_component_ref_p (t)) 168 return size; 169 170 /* Collect the list of self-references in the expression. */ 171 find_placeholder_in_expr (size, &self_refs); 172 gcc_assert (self_refs.length () > 0); 173 174 /* Obtain a private copy of the expression. */ 175 t = size; here the gcc_assert fires. Sadly self_refs has no debug info. Size is: <cond_expr 0x7ffff7448900 type <integer_type 0x7ffff745f0a8 bitsizetype public unsigned TI size <integer_cst 0x7ffff744ac00 constant visited 128> unit-size <integer_cst 0x7ffff744ac18 constant visited 16> align:128 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff745f0a8 precision:128 min <integer_cst 0x7ffff744ac30 0> max <integer_cst 0x7ffff745e848 0xffffffffffffffffffffffffffffffff>> readonly arg:0 <ge_expr 0x7ffff7470640 type <boolean_type 0x7ffff746ae70 boolean sizes-gimplified public visited unsigned QI size <integer_cst 0x7ffff744aca8 constant visited 8> unit-size <integer_cst 0x7ffff744acc0 constant visited 1> align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff746ae70 precision:8 min <integer_cst 0x7ffff74680d8 0> max <integer_cst 0x7ffff7468000 255> context <translation_unit_decl 0x7ffff7454168 a-assert.adb> RM size <integer_cst 0x7ffff744afa8 1> RM max <integer_cst 0x7ffff7468108 1>> readonly visited arg:0 <component_ref 0x7ffff74487e0 type <integer_type 0x7ffff746c1f8 positive___XDLU_1__2147483647> readonly visited arg:0 <indirect_ref 0x7ffff744b7c0 type <record_type 0x7ffff746cc78 string___XUB> readonly nothrow visited arg:0 <component_ref 0x7ffff7448750 type <pointer_type 0x7ffff746cd20> visited arg:0 <placeholder_expr 0x7ffff7468510 type <record_type 0x7ffff746cf18 string___XUP> visited> arg:1 <field_decl 0x7ffff7467a18 P_BOUNDS>>> arg:1 <field_decl 0x7ffff7473260 UB0>> arg:1 <component_ref 0x7ffff74487b0 type <integer_type 0x7ffff746c1f8 positive___XDLU_1__2147483647> readonly visited arg:0 <indirect_ref 0x7ffff744b7c0> arg:1 <field_decl 0x7ffff74731c8 LB0>>> arg:1 <mult_expr 0x7ffff74706e0 type <integer_type 0x7ffff745f0a8 bitsizetype> readonly arg:0 <nop_expr 0x7ffff744b8c0 type <integer_type 0x7ffff745f0a8 bitsizetype> readonly arg:0 <plus_expr 0x7ffff74706b8 type <integer_type 0x7ffff745f000 sizetype> readonly arg:0 <minus_expr 0x7ffff7470690 type <integer_type 0x7ffff745f000 sizetype> readonly arg:0 <nop_expr 0x7ffff744b840 type <integer_type 0x7ffff745f000 sizetype> readonly visited arg:0 <component_ref 0x7ffff74487e0>> arg:1 <nop_expr 0x7ffff744b820 type <integer_type 0x7ffff745f000 sizetype> readonly visited arg:0 <component_ref 0x7ffff74487b0>>> arg:1 <integer_cst 0x7ffff744acc0 1>>> arg:1 <integer_cst 0x7ffff744aca8 8>> arg:2 <integer_cst 0x7ffff744ac30 type <integer_type 0x7ffff745f0a8 bitsizetype> constant 0>> <PLACEHOLDER_EXPR struct >.P_BOUNDS->UB0 >= <PLACEHOLDER_EXPR struct >.P_BOUNDS->LB0 ? (bitsizetype) (((sizetype) <PLACEHOLDER_EXPR struct >.P_BOUNDS->UB0 - (sizetype) <PLACEHOLDER_EXPR struct >.P_BOUNDS->LB0) + 1) * 8 : 0; I am not expert on Ada type sizes but it seems like well formed expression. and backtrace is: #0 _Z14internal_errorPKcz (gmsgid=0xac <error: Cannot access memory at address 0xac>) at ../../gcc/diagnostic.c:1752 #1 0x00000000010ba114 in _Z11fancy_abortPKciS0_ (file=0x23a38a8 "in %s, at %s:%d", line=172, function=0x1e507bb "self_referential_size") at ../../gcc/diagnostic.c:1824 #2 0x00000000019b7dcb in _Z13variable_sizeP9tree_node (size=0x7ffff7448900) at ../../gcc/stor-layout.c:172 #3 _Z13variable_sizeP9tree_node (size=0x7ffff7448900) at ../../gcc/stor-layout.c:67 #4 0x000000000128f4e0 in finalize_type_size (type=0x7ffff746c3f0) at ../../gcc/stor-layout.c:1967 #5 0x000000000128df40 in _Z11layout_typeP9tree_node (type=0x23a38a8) at ../../gcc/stor-layout.c:2625 #6 0x000000000190e307 in _ZL18build_array_type_1P9tree_nodeS0_bbb.lto_priv.0 (elt_type=0x7ffff745f3f0, index_type=0x7ffff746c348, typeless_storage=59, shared=172, set_canonical=59) at ../../gcc/tree.c:8194 #7 0x0000000001567bcc in _Z18gnat_to_gnu_entityiP9tree_nodeb (gnat_entity=37370024, gnu_expr=0x1e507bb, definition=59) at ../../gcc/ada/gcc-interface/decl.c:2366 #8 0x00000000015618f5 in _Z16gnat_to_gnu_typei (gnat_entity=37370024) at ../../gcc/ada/gcc-interface/decl.c:4887 #9 0x00000000015687a9 in _Z18gnat_to_gnu_entityiP9tree_nodeb (gnat_entity=37370024, gnu_expr=0x1e507bb, definition=59) at ../../gcc/ada/gcc-interface/decl.c:4814 #10 0x00000000015618f5 in _Z16gnat_to_gnu_typei (gnat_entity=37370024) at ../../gcc/ada/gcc-interface/decl.c:4887 #11 0x00000000019ea47c in gigi (gnat_root=37370024, max_gnat_node=31786939, number_name=30016059, nodes_ptr=0xac, flags_ptr=0x1ca023b, next_node_ptr=0x73, prev_node_ptr=0x0, elists_ptr=0x0, elmts_ptr=0x0, strings_ptr=0x0, string_chars_ptr=0x0, list_headers_ptr=0x0, number_file=12, file_info_ptr=0x7fffffffe3c0, standard_boolean=16, standard_integer=37, standard_character=107, standard_long_long_float=100, standard_exception_type=1704, gigi_operating_mode=0) at ../../gcc/ada/gcc-interface/trans.c:463 #12 0x00000000019e406d in back_end__call_back_end (mode=(unknown: 1704)) at ../../gcc/ada/back_end.adb:155 #13 0x0000000001928eed in _ada_gnat1drv () at ../../gcc/ada/gnat1drv.adb:1608 #14 0x0000000001910a4b in _ZL15gnat_parse_filev.lto_priv.0 () at ../../gcc/ada/gcc-interface/misc.c:118 #15 0x00000000019107f4 in _ZL12compile_filev.lto_priv.0 () at ../../gcc/toplev.c:460 #16 0x00000000018f3296 in _ZN6toplev4mainEiPPc (this=0x7fffffffe63e, argc=21, argv=0x7fffffffe728) at ../../gcc/toplev.c:2321 #17 0x00000000018f26ec in main (argc=30016059, argv=0x1ca023b) at ../../gcc/main.c:39 Breakpointing on 171 works and vector seems to be filled in. However the disasembly shows: 0x00000000019b7db2 <+98>: callq 0x1a1c050 <_Z24find_placeholder_in_exprP9tree_nodeP3vecIS0_7va_heap6vl_ptrE> => 0x00000000019b7db7 <+103>: mov $0x1e507bb,%edx 0x00000000019b7dbc <+108>: mov $0xac,%esi 0x00000000019b7dc1 <+113>: mov $0x1ca0231,%edi 0x00000000019b7dc6 <+118>: callq 0x10ba0f0 <_Z11fancy_abortPKciS0_> so it seems that the vector length test is completely optimized out in function _Z13variable_sizeP9tree_node (after call to _Z24find_placeholder_in_exprP9tree_nodeP3vecIS0_7va_heap6vl_ptrE).