https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110580
Bug ID: 110580 Summary: [14 Regression] gcc fails to typecheck nix-2.16.1 source: error: invalid initialization of reference of type Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org Target Milestone: --- Created attachment 55495 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55495&action=edit nar-accessor.cc.cc.xz Originally observed the build failure on nix-2.16.1 source when building with gcc r14-2344-g9f4f833455bb35. I suspect it might be a form of https://gcc.gnu.org/PR110523 regression. But filing just in case. Attached unmodified preprocessed example. The build succeeds on gcc-13: $ g++-13 -c nar-accessor.cc.cc -std=c++2a # ok $ g++-14 -c nar-accessor.cc.cc -std=c++2a nar-accessor.cc.cc: In instantiation of 'std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Val>, std::_Select1st<std::pair<const _Key, _Val> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> >::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::emplace(_Args&& ...) [with _Args = {std::basic_string_view<char, std::char_traits<char> >, nix::NarMember}; _Key = std::__cxx11::basic_string<char>; _Tp = nix::NarMember; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, nix::NarMember> >; typename std::_Rb_tree<_Key, std::pair<const _Key, _Val>, std::_Select1st<std::pair<const _Key, _Val> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> >::other>::iterator = std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, nix::NarMember> >; typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> >::other = std::allocator<std::pair<const std::__cxx11::basic_string<char>, nix::NarMember> >; typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Val> > = __gnu_cxx::__alloc_traits<std::allocator<std::pair<const std::__cxx11::basic_string<char>, nix::NarMember> >, std::pair<const std::__cxx11::basic_string<char>, nix::NarMember> >::rebind<std::pair<const std::__cxx11::basic_string<char>, nix::NarMember> >; typename _Allocator::value_type = std::pair<const std::__cxx11::basic_string<char>, nix::NarMember>]': nar-accessor.cc.cc:126951:62: required from here nar-accessor.cc.cc:33745:23: error: invalid initialization of reference of type 'const std::map<std::__cxx11::basic_string<char>, nix::NarMember>::key_type&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'std::basic_string_view<char>' 33745 | const key_type& __k = __a; | ^~~ $ g++ -v |& unnix Using built-in specs. COLLECT_GCC=/<<NIX>>/gcc-14.0.0/bin/g++ COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-14.0.0/libexec/gcc/x86_64-unknown-linux-gnu/14.0.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 99999999 (experimental) (GCC)