[Mlir-commits] [mlir] [mlir] explicitly delete copy ctor to prevent copying DialectRegistry and OperationState (PR #140963)

Mehdi Amini llvmlistbot at llvm.org
Fri May 23 03:16:04 PDT 2025


joker-eph wrote:

> the problem is they are not being implicitly deleted because (as the original issue documents) 

I don't get it what you mean by "they are not being implicitly deleted"

> SmallVectorImpl defines a copy ctor that is not smart enough.

Maybe but neither the description/title here neither the bug are very clear to me on what's happening actually.

The title here says: "explicitly delete copy ctor to prevent copying DialectRegistry and OperationState", which implies that right now without explicitly deleting them we can copy them. But how do you copy them today?

Here is a minimal test cases showing why the current description of the issue is confusing to me:
```
#include <memory>
class Bar {};
struct Foo {  
  std::unique_ptr<Bar> ptr;
};
void copy(Foo f1, Foo f2) {
   f1 = f2;
}
```

Yield:

```
<source>:8:9: error: use of deleted function 'Foo& Foo::operator=(const Foo&)'
    8 |    f1 = f2;
      |         ^~
<source>:3:8: note: 'Foo& Foo::operator=(const Foo&)' is implicitly deleted because the default definition would be ill-formed:
    3 | struct Foo {
      |        ^~~
```

(same with the copy ctor).



https://github.com/llvm/llvm-project/pull/140963


More information about the Mlir-commits mailing list