https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Little bit less undefined - reconstructed the original symtab_node *ref argument of get_availability. Maybe we're confused about the upcast to varpool_node? template <typename T> struct reinterpret_is_a_helper { template <typename U> static T cast(U p) { return T(p); } }; template <typename, typename U> bool is_a(U); template <typename T, typename U> T dyn_cast(U p) { if (is_a<T>(p)) return reinterpret_is_a_helper<T>::cast(p); return 0; } enum tree_node_structure_enum { TS_DECL_COMMON }; void contains_struct_check(int, tree_node_structure_enum, const char *, int, const char *); enum availability { AVAIL_NOT_AVAILABLE, AVAIL_AVAILABLE }; struct symtab_node { symtab_node *ultimate_alias_target(); unsigned definition : 1; unsigned in_other_partition : 1; }; struct varpool_node : symtab_node { availability get_availability(symtab_node *); varpool_node *ultimate_alias_target(symtab_node *); unsigned : 1; }; inline symtab_node *symtab_node::ultimate_alias_target() { dyn_cast<varpool_node *>(this)->get_availability(this); dyn_cast<varpool_node *>(this)->get_availability(this); return 0; } inline varpool_node *varpool_node::ultimate_alias_target(symtab_node *) { symtab_node __trans_tmp_1 = *symtab_node::ultimate_alias_target(); varpool_node *n = dyn_cast<varpool_node *>(&__trans_tmp_1); return n; } availability varpool_node::get_availability(symtab_node *ref) { if (definition && in_other_partition) return AVAIL_NOT_AVAILABLE; ultimate_alias_target(ref); contains_struct_check(0, TS_DECL_COMMON, "", 5, __FUNCTION__); return AVAIL_AVAILABLE; }