https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94217
--- Comment #3 from Nicholas Krause <xerofoify at gmail dot com> --- (In reply to Marek Polacek from comment #2) > (In reply to Nicholas Krause from comment #1) > > Hi Marin, > > I've not sure if this is correct but it does not ICE with this fix: > > tree off = fold_convert (ptr_type_node, op1); > > - return build_fold_addr_expr_loc > > - (loc, > > + return build1_loc > > + (loc, ADDR_EXPR, TREE_TYPE (op0), > > fold_build2 (MEM_REF, > > TREE_TYPE (TREE_TYPE (op0)), > > unshare_expr (op0), off)); > > > > should actually be: > > (EXPR_LOCATION(off), ADDR_EXPR, TREE_TYPE (op0), > > fold_build2 (MEM_REF, > > TREE_TYPE (TREE_TYPE (op0)), > > unshare_expr (op0), off)); > > Huh? Why do you think that changing the location should fix the ICE? > That's a completely random change that you never bothered to test, because > it doesn't fix the crash. Here is my exact output of testing the change: [xerofoify@gcc2-power8 bin]$ ./g++ star.ii -c -flto -O2 -o x.o && ./gcc -shared x.o star.ii: In member function ‘int B< <template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3>, <template-parameter-1-4>, <template-parameter-1-5> >::_S_key()’: star.ii:9:19: warning: no return statement in function returning non-void [-Wreturn-type] 9 | int _S_key() { } | ^ star.ii: In member function ‘int B< <template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3>, <template-parameter-1-4>, <template-parameter-1-5> >::_M_insert_(int*, int*, _Arg&&, _NodeGen&)’: star.ii:24:1: warning: no return statement in function returning non-void [-Wreturn-type] 24 | } | ^ If you look at the revision mentioned for this bug in gimple-fold.c here: tree off = fold_convert (ptr_type_node, op1); - return build_fold_addr_expr_loc - (loc, + return build1_loc + (loc, ADDR_EXPR, TREE_TYPE (op0), that's incorrect as loc is not the tree we want but off and from that the EXPR_LOCATION of that tree. Does that make more sense now?