https://gcc.gnu.org/g:feccb9c9cd6ccab3fa75e2ca3f533e02de15750f
commit r16-5299-gfeccb9c9cd6ccab3fa75e2ca3f533e02de15750f Author: Jason Merrill <[email protected]> Date: Fri Nov 14 23:29:38 2025 +0530 c++/modules: using builtin Here, when we try to bring "memset" back into the global namespace, we find the built-in, see that it's the same declaration (because the module brought it into the other namespace with a using-declaration), and decide that we don't need to do anything. But we still need a non-hidden overload. gcc/cp/ChangeLog: * name-lookup.cc (do_nonmember_using_decl): Handle hidden better. gcc/testsuite/ChangeLog: * g++.dg/modules/using-33_a.C: New test. * g++.dg/modules/using-33_b.C: New test. Diff: --- gcc/cp/name-lookup.cc | 6 +++++- gcc/testsuite/g++.dg/modules/using-33_a.C | 10 ++++++++++ gcc/testsuite/g++.dg/modules/using-33_b.C | 10 ++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 984d37c2089f..abb0d48fb666 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -5404,7 +5404,11 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p, namespace. We will still want to insert it if it is revealing a not-revealed thing. */ found = true; - if (!revealing_p) + if (old.hidden_p ()) + /* The function was merged with a hidden built-in; + insert it again as not hidden. */ + found = false; + else if (!revealing_p) ; else if (old.using_p ()) { diff --git a/gcc/testsuite/g++.dg/modules/using-33_a.C b/gcc/testsuite/g++.dg/modules/using-33_a.C new file mode 100644 index 000000000000..949eade2cd9d --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-33_a.C @@ -0,0 +1,10 @@ +// { dg-additional-options "-fmodules" } +module; + +#include <string.h> + +export module M; + +namespace N { + export using ::memset; +} diff --git a/gcc/testsuite/g++.dg/modules/using-33_b.C b/gcc/testsuite/g++.dg/modules/using-33_b.C new file mode 100644 index 000000000000..342014666ca0 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-33_b.C @@ -0,0 +1,10 @@ +// { dg-additional-options "-fmodules" } +import M; + +using N::memset; + +int main() +{ + int i = 1; + memset (&i, 42, 1); +}
