Skip to content

fix: fix compile error on macOS with clang 21#237

Merged
lxy-9602 merged 1 commit into
alibaba:mainfrom
wgtmac:fix_clang21
Apr 20, 2026
Merged

fix: fix compile error on macOS with clang 21#237
lxy-9602 merged 1 commit into
alibaba:mainfrom
wgtmac:fix_clang21

Conversation

@wgtmac
Copy link
Copy Markdown
Contributor

@wgtmac wgtmac commented Apr 18, 2026

Purpose

Compiling paimon-cpp on macOS with clang 21 has some minor issues.

Tests

N/A

API and Format

N/A

Documentation

N/A

Generative AI tooling

No

Copilot AI review requested due to automatic review settings April 18, 2026 12:49
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 18, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes several macOS clang 21 compilation issues by resolving type-mismatch/override problems and ensuring template calls select the intended overloads in the blob/avro format code paths.

Changes:

  • Fix std::min type deduction issues by explicitly selecting uint64_t and casting to uint32_t where InputStream::Read expects uint32_t.
  • Fix MemoryPoolImpl::Realloc signature to correctly override MemoryPool::Realloc on platforms where size_t != uint64_t.
  • Reorder Blob::FromPath definitions so Blob::Impl is complete when used with std::make_unique.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/paimon/format/blob/blob_format_writer.cpp Makes read-chunk sizing compile-clean by disambiguating std::min and casting for Read(...).
src/paimon/format/avro/avro_input_stream_impl.cpp Adjusts Read(...) sizing to match uint32_t API requirements.
src/paimon/common/memory/memory_pool.cpp Fixes Realloc override signature for cross-platform compilation.
src/paimon/common/data/blob.cpp Moves FromPath implementations below Blob::Impl definition to avoid incomplete-type issues.
Comments suppressed due to low confidence (1)

src/paimon/common/memory/memory_pool.cpp:62

  • total_allocated_size is an atomic<int64_t>, but new_size - old_size is computed in size_t (unsigned). When shrinking, this relies on unsigned underflow and implementation-defined conversion to produce a negative delta, which is brittle and can break accounting or trigger compiler diagnostics. Compute the delta in a signed type explicitly (e.g., int64_t delta = static_cast<int64_t>(new_size) - static_cast<int64_t>(old_size)) before calling fetch_add (same applies to the similar fetch_add(new_size - old_size) in the aligned branch).
void* MemoryPoolImpl::Realloc(void* p, size_t old_size, size_t new_size, uint64_t alignment) {
    if (alignment == 0) {
        void* memptr = ::realloc(p, new_size);
        total_allocated_size.fetch_add(new_size - old_size);
        max_allocated.store(std::max(total_allocated_size.load(), max_allocated.load()));

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/paimon/format/avro/avro_input_stream_impl.cpp
Copy link
Copy Markdown
Collaborator

@lxy-9602 lxy-9602 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@lxy-9602 lxy-9602 merged commit 474f76b into alibaba:main Apr 20, 2026
12 of 13 checks passed
@wgtmac
Copy link
Copy Markdown
Contributor Author

wgtmac commented Apr 20, 2026

Thank you, @lxy-9602!

@Smith-Cruise
Copy link
Copy Markdown
Contributor

@wgtmac Hi, can you compile passed on Mac?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants