https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103993
Bug ID: 103993 Summary: Incorrect error generated by mismatched-new-delete Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jjlindal at gmail dot com Target Milestone: --- $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20211203/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.1 20211203 (Red Hat 11.2.1-7) (GCC) $ g++ -std=c++17 -D_J_HAS_PROC -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_XFT_NO_COMPAT_ -I/usr/include/freetype2 -D_J_UNIX -D_J_HAS_XINERAMA -Wall -Werror -I../include -I/usr/include/freetype2 -I/usr/include/libxml2 -O2 -c -o code/JSimpleProcess.o code/JSimpleProcess.cpp -save-temps In file included from /usr/local/include/ace/Svc_Handler.h:344, from ../include/jx-af/jcore/JNetworkProtocolBase.h:11, from ../include/jx-af/jcore/JMessageProtocol.h:11, from ../include/jx-af/jcore/JSimpleProcess.h:16, from code/JSimpleProcess.cpp:18: In static member function ‘static void ACE_Svc_Handler<PEER_STREAM, SYNCH_TRAITS>::operator delete(void*) [with PEER_STREAM = ACE_LSOCK_Stream; SYNCH_TRAITS = ACE_MT_SYNCH]’, inlined from ‘JSimpleProcess::JSimpleProcess(pid_t, int, bool)’ at code/JSimpleProcess.cpp:322:30: /usr/local/include/ace/Svc_Handler.cpp:117:3: error: ‘void operator delete [](void*)’ called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete] 117 | ::delete [] static_cast <char *> (obj); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ code/JSimpleProcess.cpp: In constructor ‘JSimpleProcess::JSimpleProcess(pid_t, int, bool)’: code/JSimpleProcess.cpp:322:37: note: returned from ‘static void* ACE_Svc_Handler<PEER_STREAM, SYNCH_TRAITS>::operator new(size_t) [with PEER_STREAM = ACE_LSOCK_Stream; SYNCH_TRAITS = ACE_MT_SYNCH]’ 322 | itsLink = new ProcessLink(fd); | ^ In file included from /usr/local/include/ace/Svc_Handler.h:344, from ../include/jx-af/jcore/JNetworkProtocolBase.h:11, from ../include/jx-af/jcore/JMessageProtocol.h:11, from ../include/jx-af/jcore/JSimpleProcess.h:16, from code/JSimpleProcess.cpp:18: In static member function ‘static void ACE_Svc_Handler<PEER_STREAM, SYNCH_TRAITS>::operator delete(void*) [with PEER_STREAM = ACE_LSOCK_Stream; SYNCH_TRAITS = ACE_MT_SYNCH]’, inlined from ‘JSimpleProcess::JSimpleProcess(pid_t, int, bool)’ at code/JSimpleProcess.cpp:322:30: /usr/local/include/ace/Svc_Handler.cpp:117:3: error: ‘void operator delete [](void*)’ called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete] 117 | ::delete [] static_cast <char *> (obj); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ code/JSimpleProcess.cpp: In constructor ‘JSimpleProcess::JSimpleProcess(pid_t, int, bool)’: code/JSimpleProcess.cpp:322:37: note: returned from ‘static void* ACE_Svc_Handler<PEER_STREAM, SYNCH_TRAITS>::operator new(size_t) [with PEER_STREAM = ACE_LSOCK_Stream; SYNCH_TRAITS = ACE_MT_SYNCH]’ 322 | itsLink = new ProcessLink(fd); | ^ cc1plus: all warnings being treated as errors