https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119154
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Though ===pr119154-1.C=== #include "pr119154-1.h" import foo; int main(){return 0;} ===pr119154-1.h=== extern "C" { extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, __SIZE_TYPE__ __n) noexcept (true); #ifdef _FORTIFY_SOURCE extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, __SIZE_TYPE__ __n, __SIZE_TYPE__ __ns) noexcept (true); extern wchar_t *__wmemset_alias (wchar_t *__s, wchar_t __c, __SIZE_TYPE__ __n) noexcept (true) __asm__ ("wmemset"); extern wchar_t *__wmemset_chk_warn (wchar_t *__s, wchar_t __c, __SIZE_TYPE__ __n, __SIZE_TYPE__ __ns) noexcept (true) __asm__ ("__wmemset_chk") __attribute__((__warning__ ("wmemset called with length bigger than size of destination buffer"))); extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) wchar_t * __attribute__ ((__leaf__)) wmemset (wchar_t *__s, wchar_t __c, __SIZE_TYPE__ __n) noexcept (true) { return (((__builtin_object_size (__s, 0)) == (long unsigned int) -1 || (((__typeof (__n)) 0 < (__typeof (__n)) -1 || (__builtin_constant_p (__n) && (__n) > 0)) && __builtin_constant_p ((((long unsigned int) (__n)) <= ((__builtin_object_size (__s, 0))) / ((sizeof (wchar_t))))) && (((long unsigned int) (__n)) <= ((__builtin_object_size (__s, 0))) / ((sizeof (wchar_t)))))) ? __wmemset_alias (__s, __c, __n) : ((((__typeof (__n)) 0 < (__typeof (__n)) -1 || (__builtin_constant_p (__n) && (__n) > 0)) && __builtin_constant_p ((((long unsigned int) (__n)) <= (__builtin_object_size (__s, 0)) / (sizeof (wchar_t)))) && !(((long unsigned int) (__n)) <= (__builtin_object_size (__s, 0)) / (sizeof (wchar_t)))) ? __wmemset_chk_warn (__s, __c, __n, (__builtin_object_size (__s, 0)) / (sizeof (wchar_t))) : __wmemset_chk (__s, __c, __n, (__builtin_object_size (__s, 0)) / (sizeof (wchar_t))))); } #endif } ===pr119154-2.C=== module; #include "pr119154-1.h" #include "pr119154-2.h" export module foo; export namespace foo { using foo::wmemset; } ===pr119154-2.h=== extern "C++" { namespace foo { using ::wmemset; } } g++ -std=c++23 -O3 -fmodules -S pr119154-2.C -D_FORTIFY_SOURCE g++ -std=c++23 -O0 -fmodules -S pr119154-1.C doesn't reproduce it. Note, one of the templates actualy uses wmemset: static constexpr char_type* assign(char_type* __s, size_t __n, char_type __a) { if (__n == 0) return __s; if (std::__is_constant_evaluated()) return __gnu_cxx::char_traits<char_type>::assign(__s, __n, __a); return wmemset(__s, __a, __n); } That is something that doesn't happen in the above testcase.