Compiling valgrind git (bc2f62950ccb12f79072b7eacc9ec43ec244496a) on Ubuntu Mantic using Clang 16 (Ubuntu clang version 16.0.6 (9)) with a GCC 13 (gcc (Ubuntu 13.2.0-1ubuntu1) 13.2.0) installation currently fails with: ./autogen.sh ./configure CC=clang CXX=clang++ make .... clang++ -DHAVE_CONFIG_H -I. -I../.. -I../.. -I../../include -I../../coregrind -I../../include -I../../VEX/pub -I../../VEX/pub -DVGA_amd64=1 -DVGO_linux=1 -DVGP_amd64_linux=1 -DVGPV_amd64_linux_vanilla=1 -std=c++17 -Wno-mismatched-new-delete -MT cxx17_aligned_new-cxx17_aligned_new.o -MD -MP -MF .deps/cxx17_aligned_new-cxx17_aligned_new.Tpo -c -o cxx17_aligned_new-cxx17_aligned_new.o `test -f 'cxx17_aligned_new.cpp' || echo './'`cxx17_aligned_new.cpp cxx17_aligned_new.cpp:25:5: error: no matching function for call to 'operator delete' operator delete(myClass, 64U, std::align_val_t(64U)); ^~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:155:6: note: candidate function not viable: no known conversion from 'unsigned int' to 'std::align_val_t' for 2nd argument void operator delete(void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:180:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:153:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:144:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:130:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete(void*) _GLIBCXX_USE_NOEXCEPT ^ cxx17_aligned_new.cpp:28:5: error: no matching function for call to 'operator delete[]' operator delete [](myClass5, 320U, std::align_val_t(64U)); ^~~~~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:163:6: note: candidate function not viable: no known conversion from 'unsigned int' to 'std::align_val_t' for 2nd argument void operator delete[](void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:181:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:161:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:146:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:132:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT ^ 2 errors generated. The same occurs using Fedora Rawhide with Clang 16 (clang version 16.0.6 (Fedora 16.0.6-3.fc39)) & GCC 13 (gcc (GCC) 13.2.1 20230728 (Red Hat 13.2.1-1)): clang++ -DHAVE_CONFIG_H -I. -I../.. -I../.. -I../../include -I../../coregrind -I../../include -I../../VEX/pub -I../../VEX/pub -DVGA_amd64=1 -DVGO_linux=1 -DVGP_amd64_linux=1 -DVGPV_amd64_linux_vanilla=1 -std=c++17 -Wno-mismatched-new-delete -MT cxx17_aligned_new-cxx17_aligned_new.o -MD -MP -MF .deps/cxx17_aligned_new-cxx17_aligned_new.Tpo -c -o cxx17_aligned_new-cxx17_aligned_new.o `test -f 'cxx17_aligned_new.cpp' || echo './'`cxx17_aligned_new.cpp cxx17_aligned_new.cpp:25:5: error: no matching function for call to 'operator delete' operator delete(myClass, 64U, std::align_val_t(64U)); ^~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:155:6: note: candidate function not viable: no known conversion from 'unsigned int' to 'std::align_val_t' for 2nd argument void operator delete(void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:180:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:153:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:144:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:130:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete(void*) _GLIBCXX_USE_NOEXCEPT ^ cxx17_aligned_new.cpp:28:5: error: no matching function for call to 'operator delete[]' operator delete [](myClass5, 320U, std::align_val_t(64U)); ^~~~~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:163:6: note: candidate function not viable: no known conversion from 'unsigned int' to 'std::align_val_t' for 2nd argument void operator delete[](void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:181:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:161:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:146:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/new:132:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT ^ 2 errors generated.
Does it compile if you cast the second argument to size_t e.g., operator delete(myClass, static_cast<size_t>(64U), std::align_val_t(64U)); A literal suffix would be nicer but size_t is only in C++23 (I believe https://open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0330r8.html) The code should be calling overloads 23 and 24 here https://en.cppreference.com/w/cpp/memory/new/operator_delete
I think that the testcase should be #include <cstdlib> #include <new> #include <iostream> class alignas(64) MyClass { public: int i; }; class OrdinaryClass { public: int i; }; int main() { // unsized versions MyClass* myClass = new MyClass; operator delete(myClass, std::align_val_t(64U)); MyClass* myClass5 = new MyClass[5]; operator delete [](myClass5, std::align_val_t(64U)); // sized versions myClass = new MyClass(); operator delete(myClass, 64U, std::align_val_t(64U)); myClass5 = new MyClass[5]; operator delete [](myClass5, 320U, std::align_val_t(64U)); MyClass* myClassNt = new (std::nothrow) MyClass; operator delete(myClassNt, std::align_val_t(64U)); MyClass* myClass5Nt = new (std::nothrow) MyClass[5]; operator delete [](myClass5Nt, std::align_val_t(64U)); myClassNt = new (std::nothrow) MyClass; operator delete(myClassNt, sizeof(MyClass), std::align_val_t(64U)); myClass5Nt = new (std::nothrow) MyClass[5]; operator delete [](myClass5Nt, sizeof(MyClass)*5, std::align_val_t(64U)); OrdinaryClass* oClass = new OrdinaryClass; // this is a limitation, VG does not use enough bits // to tell apart aligned and unaligned allocations // so new/aligned delete is not a mismatch operator delete(oClass, std::align_val_t(64U)); oClass = new (std::nothrow) OrdinaryClass; //delete oClass; // changed the above delete because GCC generates // a sized delete (???) whilst clang generates an ordinary delete operator delete(oClass); oClass = new OrdinaryClass[5]; delete [] oClass; oClass = new (std::nothrow) OrdinaryClass[5]; delete [] oClass; }
Should be OK now. Can you confirm? I don't have easy access to clang 16 or gcc 13 on Linux.
> Can you confirm? I don't have easy access to clang 16 or gcc 13 on Linux. I'm still seeing build failures at dc6669cee7b557945fd41417bf531c7f5c9f1093: clang -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector -Wno-format-extra-args -Wno-literal-range -Wno-tautological-constant-out-of-range-compare -Wno-self-assign -Wno-string-plus-int -Wno-uninitialized -Wno-unused-value -m64 -o badaddrvalue badaddrvalue.o clang -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector -Wno-format-extra-args -Wno-literal-range -Wno-tautological-constant-out-of-range-compare -Wno-self-assign -Wno-string-plus-int -Wno-uninitialized -Wno-unused-value -m64 -Wno-free-nonheap-object -o badfree badfree-badfree.o clang -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector -Wno-format-extra-args -Wno-literal-range -Wno-tautological-constant-out-of-range-compare -Wno-self-assign -Wno-string-plus-int -Wno-uninitialized -Wno-unused-value -m64 -o badjump badjump.o cxx17_aligned_new.cpp:25:5: error: no matching function for call to 'operator delete' operator delete(myClass, 64U, std::align_val_t(64U)); ^~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:155:6: note: candidate function not viable: no known conversion from 'unsigned int' to 'std::align_val_t' for 2nd argument void operator delete(void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:180:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:153:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:144:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:130:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete(void*) _GLIBCXX_USE_NOEXCEPT ^ cxx17_aligned_new.cpp:28:5: error: no matching function for call to 'operator delete[]' operator delete [](myClass5, 320U, std::align_val_t(64U)); ^~~~~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:163:6: note: candidate function not viable: no known conversion from 'unsigned int' to 'std::align_val_t' for 2nd argument void operator delete[](void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:181:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:161:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:146:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:132:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT ^ cxx17_aligned_new.cpp:37:5: error: no matching function for call to 'operator delete' operator delete(myClassNt, sizeof(MyClass), std::align_val_t(64U)); ^~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:155:6: note: candidate function not viable: no known conversion from 'unsigned long' to 'std::align_val_t' for 2nd argument void operator delete(void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:180:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:153:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:144:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:130:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete(void*) _GLIBCXX_USE_NOEXCEPT ^ cxx17_aligned_new.cpp:40:5: error: no matching function for call to 'operator delete[]' operator delete [](myClass5Nt, sizeof(MyClass)*5, std::align_val_t(64U)); ^~~~~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:163:6: note: candidate function not viable: no known conversion from 'unsigned long' to 'std::align_val_t' for 2nd argument void operator delete[](void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:181:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:161:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:146:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:132:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT ^ sized_aligned_new_delete_args.cpp:31:5: error: no matching function for call to 'operator delete' operator delete(mem, uninitsize); ^~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:180:13: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'void *' for 2nd argument; take the address of the argument with & inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:144:6: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'const std::nothrow_t' for 2nd argument void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:153:6: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'std::align_val_t' for 2nd argument void operator delete(void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:130:6: note: candidate function not viable: requires 1 argument, but 2 were provided void operator delete(void*) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:155: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&) ^ sized_aligned_new_delete_args.cpp:34:5: error: no matching function for call to 'operator delete[]' operator delete[](mem, uninitsize); ^~~~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:181:13: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'void *' for 2nd argument; take the address of the argument with & inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:146:6: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'const std::nothrow_t' for 2nd argument void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:161:6: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'std::align_val_t' for 2nd argument void operator delete[](void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:132:6: note: candidate function not viable: requires 1 argument, but 2 were provided void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/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&) ^ sized_aligned_new_delete_args.cpp:37:5: error: no matching function for call to 'operator delete' operator delete(mem, uninitsize, uninitalign); ^~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:155:6: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'std::align_val_t' for 2nd argument void operator delete(void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:180:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:153:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:144:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:130:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete(void*) _GLIBCXX_USE_NOEXCEPT ^ sized_aligned_new_delete_args.cpp:40:5: error: no matching function for call to 'operator delete[]' operator delete[](mem, uninitsize, uninitalign); ^~~~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:163:6: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'std::align_val_t' for 2nd argument void operator delete[](void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:181:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:161:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:146:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:132:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT ^ 4 errors generated. clang -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector -Wno-format-extra-args -Wno-literal-range -Wno-tautological-constant-out-of-range-compare -Wno-self-assign -Wno-string-plus-int -Wno-uninitialized -Wno-unused-value -m64 -o badjump2 badjump2.o make[5]: *** [Makefile:4068: cxx17_aligned_new-cxx17_aligned_new.o] Error 1 make[5]: *** Waiting for unfinished jobs.... 4 errors generated. make[5]: *** [Makefile:4124: sized_aligned_new_delete_args-sized_aligned_new_delete_args.o] Error 1 sized_aligned_new_delete_misaligned.cpp:53:5: error: no matching function for call to 'operator delete' operator delete(mem, size, misalign); ^~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:155:6: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'std::align_val_t' for 2nd argument void operator delete(void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:180:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:153:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:144:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:130:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete(void*) _GLIBCXX_USE_NOEXCEPT ^ sized_aligned_new_delete_misaligned.cpp:57:5: error: no matching function for call to 'operator delete[]' operator delete[](mem, size, misalign); ^~~~~~~~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:163:6: note: candidate function not viable: no known conversion from 'size_t' (aka 'unsigned long') to 'std::align_val_t' for 2nd argument void operator delete[](void*, std::align_val_t, const std::nothrow_t&) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:181:13: note: candidate function not viable: requires 2 arguments, but 3 were provided inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:161:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, std::align_val_t) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:146:6: note: candidate function not viable: requires 2 arguments, but 3 were provided void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:132:6: note: candidate function not viable: requires 1 argument, but 3 were provided void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT ^ 2 errors generated. make[5]: *** [Makefile:4138: sized_aligned_new_delete_misaligned-sized_aligned_new_delete_misaligned.o] Error 1
(In reply to fanquake from comment #4) > > Can you confirm? I don't have easy access to clang 16 or gcc 13 on Linux. > > I'm still seeing build failures at dc6669cee7b557945fd41417bf531c7f5c9f1093: > > cxx17_aligned_new.cpp:25:5: error: no matching function for call to > 'operator delete' > operator delete(myClass, 64U, std::align_val_t(64U)); > ^~~~~~~~~~~~~~~ > /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/new:155:6: > note: candidate function not viable: no known conversion from 'unsigned int' > to 'std::align_val_t' for 2nd argument > void operator delete(void*, std::align_val_t, const std::nothrow_t&) > ^ I don't understand why it is trying to resolve the call to that overload. It looks to me like a problem with your combination of LLVM 16 and GCC libstdc++13. For GCC 11.2 the list of overloads is grep "operator delete(" ./libsupc++/new void operator delete(void*) _GLIBCXX_USE_NOEXCEPT void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT void operator delete(void*, std::align_val_t) void operator delete(void*, std::align_val_t, const std::nothrow_t&) void operator delete(void*, std::size_t, std::align_val_t) There are only two candidates with 3 arguments, so the overload set should be reduced to just those two, and it should resolve to the last one. For some reason you are only seeing one. In GCC 11.2 that is controlled by #if __cpp_sized_deallocation. LLVM should be the same. The files are being compiled with -std=c++17? I just tried clang++14 and it does not set __cpp_sized_deallocation: clang++ -std=c++17 -dM -E -x c++ /dev/null | grep sized [nothing] but g++ 11.2 does set it g++ -std=c++17 -dM -E -x c++ /dev/null | grep sized #define __cpp_sized_deallocation 201309L That looks right to me.
It's possible that LLVM + libstdc++ disables sized delete. I'll try to find out some more.
That looks like the problem https://reviews.llvm.org/D8467 And clang++ -std=c++17 -fsized-deallocation -dM -E -x c++ /dev/null | grep sized #define __cpp_sized_deallocation 201309L
I'll try something like changing memcheck/test/Makefile.am from if HAVE_ALIGNED_CXX_ALLOC cxx17_aligned_new_SOURCES = cxx17_aligned_new.cpp cxx17_aligned_new_CXXFLAGS = -std=c++17 @FLAG_W_NO_MISMATCHED_NEW_DELETE@ sized_aligned_new_delete_args_SOURCES = sized_aligned_new_delete_args.cpp sized_aligned_new_delete_args_CXXFLAGS = ${AM_CXXFLAGS} -std=c++17 sized_aligned_new_delete_misaligned_SOURCES = sized_aligned_new_delete_misaligned.cpp sized_aligned_new_delete_misaligned_CXXFLAGS = ${AM_CXXFLAGS} -std=c++17 endif to if HAVE_ALIGNED_CXX_ALLOC cxx17_aligned_new_SOURCES = cxx17_aligned_new.cpp cxx17_aligned_new_CXXFLAGS = -std=c++17 @FLAG_W_NO_MISMATCHED_NEW_DELETE@ sized_aligned_new_delete_args_SOURCES = sized_aligned_new_delete_args.cpp sized_aligned_new_delete_args_CXXFLAGS = ${AM_CXXFLAGS} -std=c++17 sized_aligned_new_delete_misaligned_SOURCES = sized_aligned_new_delete_misaligned.cpp sized_aligned_new_delete_misaligned_CXXFLAGS = ${AM_CXXFLAGS} -std=c++17 # clang turns off sized delete when using libstdc++ if COMPILER_IS_CLANG cxx17_aligned_new_CXXFLAGS += -fsized-deallocation sized_aligned_new_delete_args_CXXFLAGS += -fsized-deallocation sized_aligned_new_delete_misaligned_CXXFLAGS += -fsized-deallocation endif endif
commit 566b39a46f273710857938f66672213a4617beeb (HEAD -> master, origin/master, origin/HEAD) Author: Paul Floyd <pjfloyd@wanadoo.fr> Date: Fri Aug 25 22:11:27 2023 +0200 Bug 473677 - make check compile failure with Clang 16 based on GCC 13.x