https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107938
Bug ID: 107938 Summary: ICE directly returning `this` of `extern` variable in template Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: johelegp at gmail dot com CC: johelegp at gmail dot com Target Milestone: --- See https://compiler-explorer.com/z/4d1esaber. ```C++ struct Q { int n; constexpr const Q* operator()(auto) const { return this; } }; extern const Q q; template<int> constexpr const Q* p = q(0); ``` ``` <source>:9:27: internal compiler error: Segmentation fault 9 | constexpr const Q* p = q(0); | ^ 0x22e3a9e internal_error(char const*, ...) ???:0 0xce2006 convert_for_initialization(tree_node*, tree_node*, tree_node*, int, impl_conv_rhs, tree_node*, int, int) ???:0 0xced3f0 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ???:0 0xb22845 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int) ???:0 0xc20997 c_parse_file() ???:0 0xd5b949 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1 ``` Being less direct works: https://compiler-explorer.com/z/jn99aG36e.