zygoloid wrote:

Is it correct to mark destructors' `this` pointers as `dead_on_return`? What 
about this case:

```c++
struct X {
  int n;
  ~X() {
    this[n].n = 0;
  }
};
void f() {
  X xs[] = {42, 0};
}
```

I think that's valid -- you can use a pointer to an array element to reach 
other elements of the array, even if the pointer is the `this` pointer -- but 
if the `this[n].n = 0` store is treated as dead, then destroying `xs[1]` won't 
set `xs[0].n` to `0`, so destroying `xs[0]` will store outside the array.

I think we'd need to add a size to the `dead_on_return` attribute to indicate 
how many bytes are dead; we can't assume all memory reachable through `this` is 
dead.

https://github.com/llvm/llvm-project/pull/166276
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to