[PATCH 2/2] c++/modules: Remove unnecessary lazy_load_pendings

Jason Merrill jason@redhat.com
Fri May 9 12:18:58 GMT 2025


On 4/21/25 6:22 AM, Nathaniel Shead wrote:
> This call is not necessary, as we don't access the bodies of any classes
> that we instantiate here.

This turns out to break

20_util/function_objects/mem_fn/constexpr.cc
std/ranges/view.cc

when modified to use import std (as attached).  For the former, I see

> In file included from /home/jason/s/gcc/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/stdc++.h:55,
>                  from /home/jason/s/gcc/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/std.cc:30,
> of module std, imported at /home/jason/gt/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/constexpr.cc:21:
> /home/jason/s/gcc/x86_64-pc-linux-gnu/libstdc++-v3/include/functional: In instantiation of ‘class std::_Mem_fn_base<int F::*, false>’:
> /home/jason/s/gcc/x86_64-pc-linux-gnu/libstdc++-v3/include/functional:211:12:   required from ‘struct std::_Mem_fn<int F::*>’
>   211 |     struct _Mem_fn<_Res _Class::*>
>       |            ^~~~~~~~~~~~~~~~~~~~~~~
> /home/jason/gt/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/constexpr.cc:36:21:   required from here
>    36 |   return std::mem_fn(&F::i)(f);
>       |          ~~~~~~~~~~~^~~~~~~
> /home/jason/s/gcc/x86_64-pc-linux-gnu/libstdc++-v3/include/functional:190:23: error: conflicting declaration of template ‘template<class _Func, class ... _BoundArgs> struct std::_Bind_check_arity’
>   190 |         friend struct _Bind_check_arity;
>       |                       ^~~~~~~~~~~~~~~~~
> /home/jason/s/gcc/x86_64-pc-linux-gnu/libstdc++-v3/include/functional:834:12: note: previous declaration ‘template<class _Func, class ... _BoundArgs> struct std::_Bind_check_arity’
>   834 |     struct _Bind_check_arity { };
>       |            ^~~~~~~~~~~~~~~~~

lookup_imported_hidden_friend is failing without the lazy_load_pendings, 
so we try and fail to push the instantiation.  Reverting this patch 
makes them pass.

Jason
-------------- next part --------------
A non-text attachment was scrubbed...
Name: std-tests.patch
Type: text/x-patch
Size: 1486 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20250509/0738b602/attachment.bin>


More information about the Gcc-patches mailing list