https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77726
Bug ID: 77726 Summary: On MinGW targets, user-defined `operator delete(void *)` is not called if the sized-deallocation version is not provided in C++14 mode when libstdc++ is linked dynamically Product: gcc Version: 6.2.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: lh_mouse at 126 dot com Target Milestone: --- Testcase: E:\Desktop>cat test.cc void *operator new(__SIZE_TYPE__ cb){ auto p = __builtin_malloc(cb); __builtin_printf("%s: %p\n", __PRETTY_FUNCTION__, p); return p; } void operator delete(void *p) noexcept { __builtin_printf("%s: %p\n", __PRETTY_FUNCTION__, p); __builtin_free(p); } #if 0 void operator delete(void *p, __SIZE_TYPE__ cb) noexcept { __builtin_printf("%s: %p, %lu\n", __PRETTY_FUNCTION__, p, (unsigned long)cb); __builtin_free(p); } #endif int main(){ delete new int; } E:\Desktop>g++ test.cc -std=c++14 -Wall -Wextra -pedantic test.cc:6:6: warning: the program should also define 'void operator delete(void*, unsigned int)' [-Wsized-deallocation] void operator delete(void *p) noexcept { ^~~~~~~~ E:\Desktop>a.exe void* operator new(unsigned int): 003F6FA0 E:\Desktop>g++ test.cc -std=c++14 -Wall -Wextra -pedantic -static test.cc:6:6: warning: the program should also define 'void operator delete(void*, unsigned int)' [-Wsized-deallocation] void operator delete(void *p) noexcept { ^~~~~~~~ E:\Desktop>a.exe void* operator new(unsigned int): 007C6CF8 void operator delete(void*): 007C6CF8 E:\Desktop>g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=C:/MinGW/MSYS2/mingw32/lib/gcc/i686-w64-mingw32/6.2.1/lto-wrapper.exe Target: i686-w64-mingw32 Configured with: ../gcc/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw 32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --enable-bootstrap --with-arch=i686 --with-tune=generic --enable-languages=c,lto,c++ --enable-shared --enable-static --enable-libatomic --enable-t hreads=mcf --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --dis able-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw32 --with-mpfr=/mi ngw32 --with-mpc=/mingw32 --with-isl=/mingw32 --with-pkgversion='gcc-6-branch HEAD with MCF thread model, built by LH_Mouse.' --with-bugurl=http://github.lhmouse.com/ --with-gnu-as --with-gnu-ld --dis able-tls --disable-sjlj-exceptions --with-dwarf2 Thread model: mcf gcc version 6.2.1 20160924 (gcc-6-branch HEAD with MCF thread model, built by LH_Mouse.)