$ g++-11 -Wall -Wextra -Wno-unused-parameter -I../llvm-12-release+assert/include -std=c++17 -fno-rtti -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -c -o test.o test.cpp
In file included from test.cpp:1:
../llvm-12-release+assert/include/llvm/IR/IRBuilder.h: In member function ‘llvm::Value* llvm::IRBuilderBase::CreateICmp(llvm::CmpInst::Predicate, llvm::Value*, llvm::Value*, const llvm::Twine&)’:
../llvm-12-release+assert/include/llvm/IR/IRBuilder.h:2385:43: warning: ‘static void llvm::User::operator delete(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
2385 | return Insert(new ICmpInst(P, LHS, RHS), Name);
| ^
The GCC warning issues false positives when one of the allocation and deallocation functions is inlined into its caller but not the other. There's some detail in GCC bugs 103993 and 100861.
Hi,
Compiler: g++-11 (Ubuntu 11-20210417-1ubuntu1) 11.0.1 20210417 (experimental) [master revision c1c86ab96c2:b6fb0ccbb48:8ae884c09fbba91e9cec391290ee4a2859e7ff41]
LLVM: 12.0.1 built locally with g++-11.
I have a repro case below that caused g++ 11 to emit mismatched-new-delete warning. This may be more of a gcc-11 problem than llvm.
Compiling it with -O0:
Compiling with -O1 will not result in warnings.