https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120125
Bug ID: 120125 Summary: ICE when using -Os and std module together Product: gcc Version: 15.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: winmikedows at hotmail dot com Target Milestone: --- Any usage of std:: things results in an instant ICE when using `import std` together with -Os in GCC 15.1 and above. MVP: ```cpp import std; int main() { std::vector<int> vec; return 0; } ``` Reproduce commands: ``` g++ -std=c++23 -fmodules -Os -c -fmodule-only -fsearch-include-path bits/std.cc g++ -std=c++23 -fmodules -Os hello.cpp -o hello.out ``` Output: ``` In file included from /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/bits/cpp_type_traits.h:42, from /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/bits/stl_algobase.h:61, from /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/algorithm:62, from /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/x86_64-linux-gnu/bits/stdc++.h:53, from /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/bits/std.cc:30, of module std, imported at ../hello.cpp:1: /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/type_traits: In substitution of 'template<class ... _Bn> std::__detail::__first_t<std::integral_constant<bool, false>, typename std::enable_if<(!(bool)(_Bn::value)), void>::type ...> std::__detail::__or_fn(int) [with _Bn = {std::is_reference<std::allocator<int> >, std::is_function<std::allocator<int> >, std::is_void<std::allocator<int> >, std::__is_array_unknown_bounds<std::allocator<int> >}]': /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/type_traits:199:41: required from 'struct std::__or_<std::is_reference<std::allocator<int> >, std::is_function<std::allocator<int> >, std::is_void<std::allocator<int> >, std::__is_array_unknown_bounds<std::allocator<int> > >' 199 | : decltype(__detail::__or_fn<_Bn...>(0)) | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/type_traits:311:13: required by substitution of 'template<class _TypeIdentity, class _NestedType> constexpr typename std::__or_<std::is_reference<_NestedType>, std::is_function<_NestedType>, std::is_void<_NestedType>, std::__is_array_unknown_bounds<_NestedType> >::type std::__is_complete_or_unbounded(_TypeIdentity) [with _TypeIdentity = std::__type_identity<std::allocator<int> >; _NestedType = std::allocator<int>]' 311 | >::type __is_complete_or_unbounded(_TypeIdentity) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/type_traits:1246:52: required from 'struct std::is_nothrow_default_constructible<std::allocator<int> >' 1246 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ ../hello.cpp:4:22: recursively required from 'constexpr std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]' 4 | std::vector<int> vec; | ^~~ ../hello.cpp:4:22: required from here /opt/compiler-explorer/gcc-15.1.0/include/c++/15.1.0/type_traits:180:12: internal compiler error: Segmentation fault 180 | auto __or_fn(int) -> __first_t<false_type, | ^~~~~~~ 0x2287465 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x22989b6 internal_error(char const*, ...) ???:0 0xb27dc5 symtab_node::add_to_same_comdat_group(symtab_node*) ???:0 0x91df53 maybe_clone_body(tree_node*) ???:0 0x9dae6a expand_or_defer_fn(tree_node*) ???:0 0x906293 lazy_load_pendings(tree_node*) ???:0 0x9bad6f lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int) ???:0 0x9ab456 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x9abc1c tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x9b1140 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*) ???:0 0x9b26c9 tsubst_template_args(tree_node*, tree_node*, int, tree_node*) ???:0 0x9b291e tsubst_argument_pack(tree_node*, tree_node*, int, tree_node*) ???:0 0x9b2664 tsubst_template_args(tree_node*, tree_node*, int, tree_node*) ???:0 0x9ab51b tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x9abe5d tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x9ab7f3 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x9b961a instantiate_template(tree_node*, tree_node*, int) ???:0 0x9c158f fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node* const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool, bool) ???:0 0x8032f9 build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ???:0 0x9d8b3e finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int) ???: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. ``` See https://godbolt.org/z/7frjxb9rn for a reproducible example. Note: removing -Os on either of the two commands, and the ICE is gone. It only appears when both commands used -Os