Commit c288607
Add Virtual Destructor to FlatIndex Class (#4381)
Summary:
Pull Request resolved: #4381
This change introduces a virtual destructor to the FlatIndex class to ensure proper cleanup of derived class objects when they are deleted through a base class pointer. This modification addresses the compiler warning about deleting objects with virtual functions but non-virtual destructors, thereby preventing potential resource leaks and undefined behavior.
Original Errors:
```
Remote action, reproduce with: `frecli cas download-action 5c1f300e23c7f3a3c0ac1e5644473bfc3940abade7d8c1496bf2adcb5b1c8181:145`
Stdout: <empty>
Stderr:
fbcode/third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/unique_ptr.h:85:1: error: delete called on non-final 'faiss::gpu::FlatIndex' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-abstract-non-virtual-dtor]
85 | delete __ptr;
| ^
fbcode/third-party-buck/platform010/build/libgcc/include/c++/trunk/bits/unique_ptr.h:361:1: note: in instantiation of member function 'std::default_delete<faiss::gpu::FlatIndex>::operator()' requested here
361 | get_deleter()(std::move(__ptr)); }
| ^
fbcode/faiss/gpu/GpuIndexFlat.cu:28:15: note: in instantiation of member function 'std::unique_ptr<faiss::gpu::FlatIndex>::~unique_ptr' requested here
28 | GpuIndexFlat::GpuIndexFlat(GpuResourcesProvider *
| ^
1 error generated.
```
Reviewed By: zhuhan0
Differential Revision: D76303668
fbshipit-source-id: 27965d6dc4fd03366d599be8a3760be1df668d5b1 parent 0e18107 commit c288607
1 file changed
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
| |||
0 commit comments