https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101140
Bug ID: 101140 Summary: [modules] no matching function for call to ‘operator new(sizetype, void*)’ Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ensadc at mailnesia dot com Target Milestone: --- $ cat new.hpp extern "C++" { void* operator new(__SIZE_TYPE__, void* p); } $ cat foo.cpp module; #include "new.hpp" export module foo; export template<class T> T* construct_at(T* p) { return ::new((void*)p) T(); } $ cat bar.cpp export module bar; import foo; void f(int* p) { construct_at(p); } $ g++ -std=c++20 -fmodules-ts -c foo.cpp $ g++ -std=c++20 -fmodules-ts -c bar.cpp In module foo, imported at bar.cpp:3: foo.cpp: In instantiation of ‘T* construct_at@foo(T*) [with T = int]’: bar.cpp:6:17: required from here foo.cpp:7:12: error: no matching function for call to ‘operator new(sizetype, void*)’ 7 | return ::new((void*)p) T(); | ^~~~~~~~~~~~~~~~~~~ <built-in>: note: candidate: ‘void* operator new(long unsigned int)’ <built-in>: note: candidate expects 1 argument, 2 provided <built-in>: note: candidate: ‘void* operator new(long unsigned int, std::align_val_t)’ <built-in>: note: no known conversion for argument 2 from ‘void*’ to ‘std::align_val_t’ bar.cpp:1:8: warning: not writing module ‘bar’ due to errors 1 | export module bar; | ^~~~~~ ==== The error disappears if "new.hpp" is included or imported in `bar.cpp`. I originally encountered this problem when using `std::construct_at` (defined in`<memory>`) in a module.