| Issue |
52997
|
| Summary |
g++ 11 warns of mismatched-new-delete
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
cktan
|
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.
```
$ cat test.cpp
#include "llvm/IR/IRBuilder.h"
void foo(llvm::IRBuilder<>& builder, llvm::BasicBlock* block)
{
builder.SetInsertPoint(block);
builder.CreateICmpEQ(0, 0);
}
```
Compiling it with -O0:
```
$ 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);
| ^
```
Compiling with -O1 will not result in warnings.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs