https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108391
Bug ID: 108391 Summary: Operator '::operator delete(void*, size_t)' was not found when clang compiled stdlibc++ Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: jincikang at gmail dot com Target Milestone: --- ```C++ // main.cpp #include <new> int main() { void* p = ::operator new[](2); ::operator delete[](p, 2); } ``` # no problem $ g++ main.cpp -std=c++20 # no problem $ clang++ main.cpp -std=c++20 -stdlib=libc++ $ clang++ main.cpp -std=c++20 main.cpp:5:3: error: no matching function for call to 'operator delete[]' ::operator delete[](p, 2); ^~~~~~~~~~~~~~~~~~~ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:146:6: note: candidate function not viable: no known conversion from 'int' to 'const std::nothrow_t' for 2nd argument void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:161:6: note: candidate function not viable: no known conversion from 'int' to 'std::align_val_t' for 2nd argument void operator delete[](void*, std::align_val_t) ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:181:13: note: candidate function not viable: no known conversion from 'int' to 'void *' for 2nd argument inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:132:6: note: candidate function not viable: requires 1 argument, but 2 were provided void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/new:163:6: note: candidate function not viable: requires 3 arguments, but 2 were provided void operator delete[](void*, std::align_val_t, const std::nothrow_t&) ^ 1 error generated * The reason is that clang does not define the macro __cpp_sized_deallocation. * I think `#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION` in libc++ might be a bit better