Skip to content

Replace C-style cast with const_cast in ReaderIO::ReleaseImpl #7

@LHT129

Description

@LHT129

Problem

In `src/io/reader_io.cpp:70`, C-style cast is used to convert `const uint8_t*` to `void*`:

```cpp
void ReaderIO::ReleaseImpl(const uint8_t* data) const {
allocator_->Deallocate((void*)data); // C-style cast
}
```

The `Deallocate()` method signature requires `void*` (non-const), but `data` is `const uint8_t*`. The C-style cast silently removes const-ness without clear intent.

Solution

Use `const_cast` to explicitly express the intent:

```cpp
allocator_->Deallocate(const_cast<uint8_t*>(data));
```

This pattern is already used in the codebase at `src/io/noncontinuous_io.h:128`.

Tasks

  • Replace C-style cast with `const_cast` in `reader_io.cpp:70`
  • Search for similar C-style casts in the same file and `src/io/` directory
  • Verify compilation passes with no new warnings
  • Run related unit tests

Acceptance Criteria

  • Code compiles without warnings
  • All related tests pass
  • No other C-style casts remain in `reader_io.cpp`

Priority

Medium

Estimated Effort

0.5-1 hour

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions