When a class is deleted, the user-defined destructor is not invoked.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 624
- Forks
- 170
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I have a problem when I try to use your open source project. Here is the source for testing.
class SimStream {
public:
int n;
double a;
char b;
SimStream() {
n = 0;
}
SimStream(double _a) {
a = _a;
}
SimStream(int _n , double _a){
n = _n; a = _a;
}
~SimStream() { printf("---------------------------------------1\n"); };
};
void doSomeThing(SimStream *t) {};
int main() {
SimStream *s = new SimStream;
doSomeThing(s);
delete s;
return 0;
}
It seems that custom destructor not called. When I delete a class,there are only memref.dealloc %alloc : memref<1x!llvm.struct<(i32, f64, i8)>> and not anything about user-defined destructor function.
I don't know what the problem is. If you can answer it, I'd appreciate it.
CXXDeleteExpr 0x559ae6f1da48 'void' Function 0x559ae6edcfa0 'operator delete' 'void (void *) noexcept'
`-ImplicitCastExpr 0x559ae6f1da30 'SimStream *' <LValueToRValue>
`-DeclRefExpr 0x559ae6f1da10 'SimStream *' lvalue Var 0x559ae6f1d4f8 's' 'SimStream *'
warning not calling destructor on delete
module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<f80, dense<128> : vector<2xi32>>, #dlti.dl_entry<i1, dense<8> : vector<2xi32>>, #dlti.dl_entry<!llvm.ptr, dense<64> : vector<4xi32>>, #dlti.dl_entry<i16, dense<16> : vector<2xi32>>, #dlti.dl_entry<i8, dense<8> : vector<2xi32>>, #dlti.dl_entry<i32, dense<32> : vector<2xi32>>, #dlti.dl_entry<f16, dense<16> : vector<2xi32>>, #dlti.dl_entry<f64, dense<64> : vector<2xi32>>, #dlti.dl_entry<!llvm.ptr<270>, dense<32> : vector<4xi32>>, #dlti.dl_entry<f128, dense<128> : vector<2xi32>>, #dlti.dl_entry<!llvm.ptr<271>, dense<32> : vector<4xi32>>, #dlti.dl_entry<!llvm.ptr<272>, dense<64> : vector<4xi32>>, #dlti.dl_entry<i64, dense<64> : vector<2xi32>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i32>, #dlti.dl_entry<"dlti.endianness", "little">>, llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu", "polygeist.target-cpu" = "x86-64", "polygeist.target-features" = "+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87", "polygeist.tune-cpu" = "generic"} {
func.func @_Z11doSomeThingP9SimStream(%arg0: memref<?x!llvm.struct<(i32, f64, i8)>>) attributes {llvm.linkage = #llvm.linkage<external>} {
return
}
func.func @main() -> i32 attributes {llvm.linkage = #llvm.linkage<external>} {
%c0_i32 = arith.constant 0 : i32
%alloc = memref.alloc() : memref<1x!llvm.struct<(i32, f64, i8)>>
%cast = memref.cast %alloc : memref<1x!llvm.struct<(i32, f64, i8)>> to memref<?x!llvm.struct<(i32, f64, i8)>>
call @_ZN9SimStreamC1Ev(%cast) : (memref<?x!llvm.struct<(i32, f64, i8)>>) -> ()
memref.dealloc %alloc : memref<1x!llvm.struct<(i32, f64, i8)>>
return %c0_i32 : i32
}
func.func @_ZN9SimStreamC1Ev(%arg0: memref<?x!llvm.struct<(i32, f64, i8)>>) attributes {llvm.linkage = #llvm.linkage<linkonce_odr>} {
%c0_i32 = arith.constant 0 : i32
%0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(i32, f64, i8)>>) -> !llvm.ptr
llvm.store %c0_i32, %0 : i32, !llvm.ptr
return
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided C++ program and inspect how its CXXDeleteExpr is lowered. The issue's MLIR output shows construction followed by memref.dealloc without a destructor call; done means the generated operation sequence invokes the user-defined destructor before deallocation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100