diff --git a/src/io/async_io/async_io.h b/src/io/async_io/async_io.h index 90c5f8496a..7c67a2c9b0 100644 --- a/src/io/async_io/async_io.h +++ b/src/io/async_io/async_io.h @@ -65,7 +65,7 @@ class AsyncIO : public BasicIO { /** * @brief Destructor that closes file descriptors and optionally removes the file. */ - ~AsyncIO() override; + ~AsyncIO(); public: /** diff --git a/src/io/buffer_io/buffer_io.h b/src/io/buffer_io/buffer_io.h index f2626e63bf..5db824e3db 100644 --- a/src/io/buffer_io/buffer_io.h +++ b/src/io/buffer_io/buffer_io.h @@ -69,7 +69,7 @@ class BufferIO : public BasicIO { * * If exist_file_ is false (file was newly created), the file is removed. */ - ~BufferIO() override { + ~BufferIO() { close(this->fd_); // remove file if (not this->exist_file_) { diff --git a/src/io/common/basic_io.h b/src/io/common/basic_io.h index b16f25be61..1d040f587a 100644 --- a/src/io/common/basic_io.h +++ b/src/io/common/basic_io.h @@ -53,11 +53,6 @@ class BasicIO { */ explicit BasicIO(Allocator* allocator) : allocator_(allocator){}; - /** - * @brief Virtual destructor to ensure proper cleanup in derived classes. - */ - virtual ~BasicIO() = default; - /** * @brief Writes data to the IO object at a specified offset. * @@ -262,6 +257,19 @@ class BasicIO { uint64_t start_{0}; protected: + /** + * @brief Protected non-virtual destructor. + * + * BasicIO uses CRTP for static polymorphism, so dynamic dispatch is never needed. + * The destructor is non-virtual to avoid introducing a vptr. + * + * The destructor is protected (not public) to prevent deletion through a raw + * BasicIO pointer at compile time. Note that std::shared_ptr> + * (used in some datacells) remains safe because the deleter is bound to the + * concrete IOTmpl type at construction time (e.g. via std::make_shared). + */ + ~BasicIO() = default; + /** * @brief Checks if the given offset is valid. * diff --git a/src/io/memory_block_io/memory_block_io.h b/src/io/memory_block_io/memory_block_io.h index 87b1e11ccf..280d4c8d25 100644 --- a/src/io/memory_block_io/memory_block_io.h +++ b/src/io/memory_block_io/memory_block_io.h @@ -66,7 +66,7 @@ class MemoryBlockIO : public BasicIO { /** * @brief Destructor that deallocates all memory blocks. */ - ~MemoryBlockIO() override; + ~MemoryBlockIO(); /** * @brief Writes data to the blocks at a specified offset. diff --git a/src/io/memory_io/memory_io.h b/src/io/memory_io/memory_io.h index 0ed167f4d4..ecdc4395f7 100644 --- a/src/io/memory_io/memory_io.h +++ b/src/io/memory_io/memory_io.h @@ -78,7 +78,7 @@ class MemoryIO : public BasicIO { /** * @brief Destructor that deallocates the memory buffer. */ - ~MemoryIO() override { + ~MemoryIO() { this->allocator_->Deallocate(buffer_); } diff --git a/src/io/mmap_io/mmap_io.h b/src/io/mmap_io/mmap_io.h index 3147aa5152..814610b957 100644 --- a/src/io/mmap_io/mmap_io.h +++ b/src/io/mmap_io/mmap_io.h @@ -66,7 +66,7 @@ class MMapIO : public BasicIO { /** * @brief Destructor that unmaps memory and closes file; optionally removes file. */ - ~MMapIO() override; + ~MMapIO(); /** * @brief Writes data to the mapped memory at a specified offset. diff --git a/src/io/noncontinuous_io/noncontinuous_io.h b/src/io/noncontinuous_io/noncontinuous_io.h index 1e1fbbbe8f..9775f2f5b4 100644 --- a/src/io/noncontinuous_io/noncontinuous_io.h +++ b/src/io/noncontinuous_io/noncontinuous_io.h @@ -66,7 +66,7 @@ class NonContinuousIO : public BasicIO> { /** * @brief Default destructor. */ - ~NonContinuousIO() override = default; + ~NonContinuousIO() = default; /** * @brief Writes data to non-continuous regions at a specified logical offset. diff --git a/src/io/reader_io/reader_io.h b/src/io/reader_io/reader_io.h index 51cdba885a..212e38fb0c 100644 --- a/src/io/reader_io/reader_io.h +++ b/src/io/reader_io/reader_io.h @@ -64,7 +64,7 @@ class ReaderIO : public BasicIO { /** * @brief Default destructor. */ - ~ReaderIO() override = default; + ~ReaderIO() = default; /** * @brief Writes data to the IO object (no-op for read-only IO).