Skip to content

Conversation

BwL1289
Copy link

@BwL1289 BwL1289 commented Aug 13, 2025

Rationale for this change

Arrow’s C++ codebase currently targets an older C++ standard. Moving to C++23 helps keep the project aligned with modern compiler defaults, enables new language features, and ensures continued compatibility with upcoming compiler versions.

During this upgrade, several forward declaration patterns used in the codebase became invalid under C++23 rules, requiring changes to maintain build correctness.

What changes are included in this PR?

This PR updates code to resolve forward declaration errors triggered by C++23 compliance checks. Specifically, it corrects invalid or outdated forward declarations that are rejected by C++23.

Applies the fixes in:

  • cpp/src/arrow/acero/asof_join_node.cc
  • cpp/src/arrow/filesystem/mockfs.cc
  • cpp/src/arrow/flight/types.h

Are these changes tested?

Yes.

Are there any user-facing changes?

No.

gorloffslava and others added 28 commits November 1, 2024 20:47
bwl1289/feat/merge-upstream
Copy link

⚠️ GitHub issue #47207 has been automatically assigned in GitHub to PR creator.

@BwL1289 BwL1289 changed the title GH-47207: [C++] Upgrade code to be compatible with C++23 GH-47207: [C++][C++23] Upgrade code to be compatible with C++23 Aug 13, 2025
@BwL1289 BwL1289 changed the title GH-47207: [C++][C++23] Upgrade code to be compatible with C++23 GH-47207: [C++][C++23] Upgrade Arrow to be compatible with C++23 Aug 13, 2025
@kou
Copy link
Member

kou commented Aug 14, 2025

Could you rebase on main to use #47318 ?

@BwL1289
Copy link
Author

BwL1289 commented Aug 15, 2025

@kou I tried rebasing just now but ran into merge conflicts I'm finding difficult to resolve. I think it's better if you do it.

@pitrou
Copy link
Member

pitrou commented Aug 21, 2025

Perhaps we should start with C++20 as in #47330 ?

@BwL1289
Copy link
Author

BwL1289 commented Aug 21, 2025

I disagree, but whatever @kou wants to do.

@kou
Copy link
Member

kou commented Aug 21, 2025

Perhaps we should start with C++20 as in #47330 ?

The link should be #45445 ?

I disagree, but whatever @kou wants to do.

Based on the current C++23 CI job failure, we need to require C++20 to pass the failure:

https://github.com/apache/arrow/actions/runs/17113416247/job/48539553905#step:6:2347

FAILED: src/arrow/CMakeFiles/arrow_array.dir/array/array_nested.cc.o 
/usr/bin/ccache /usr/bin/c++ -DARROW_HAVE_RUNTIME_AVX2 -DARROW_HAVE_RUNTIME_AVX512 -DARROW_HAVE_RUNTIME_BMI2 -DARROW_HAVE_RUNTIME_SSE4_2 -DARROW_HAVE_SSE4_2 -I/build/cpp/src -I/arrow/cpp/src -I/arrow/cpp/src/generated -Wredundant-move -Wno-noexcept-type -Wno-self-move  -fdiagnostics-color=always  -Wall -Wno-conversion -Wno-sign-conversion -Wdate-time -Wimplicit-fallthrough -Wunused-result -fno-semantic-interposition -msse4.2  -g -Werror -O0 -ggdb -g1 -std=c++23 -fPIC -MD -MT src/arrow/CMakeFiles/arrow_array.dir/array/array_nested.cc.o -MF src/arrow/CMakeFiles/arrow_array.dir/array/array_nested.cc.o.d -o src/arrow/CMakeFiles/arrow_array.dir/array/array_nested.cc.o -c /arrow/cpp/src/arrow/array/array_nested.cc
/arrow/cpp/src/arrow/array/array_nested.cc: In member function 'const std::shared_ptr<arrow::Array>& arrow::StructArray::field(int) const':
/arrow/cpp/src/arrow/array/array_nested.cc:1080:51: error: 'std::shared_ptr<_Tp> std::atomic_load(const shared_ptr<_Tp>*) [with _Tp = arrow::Array]' is deprecated: use 'std::atomic<std::shared_ptr<T>>' instead [-Werror=deprecated-declarations]
 1080 |   std::shared_ptr<Array> result = std::atomic_load(&boxed_fields_[i]);
      |                                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/memory:81,
                 from /arrow/cpp/src/arrow/array/array_nested.h:24,
                 from /arrow/cpp/src/arrow/array/array_nested.cc:18:
/usr/include/c++/14/bits/shared_ptr_atomic.h:142:5: note: declared here
  142 |     atomic_load(const shared_ptr<_Tp>* __p)
      |     ^~~~~~~~~~~
/arrow/cpp/src/arrow/array/array_nested.cc:1089:22: error: 'void std::atomic_store(shared_ptr<_Tp>*, shared_ptr<_Tp>) [with _Tp = arrow::Array]' is deprecated: use 'std::atomic<std::shared_ptr<T>>' instead [-Werror=deprecated-declarations]
 1089 |     std::atomic_store(&boxed_fields_[i], std::move(result));
      |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/shared_ptr_atomic.h:183:5: note: declared here
  183 |     atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
      |     ^~~~~~~~~~~~
/arrow/cpp/src/arrow/array/array_nested.cc: In member function 'std::shared_ptr<arrow::Array> arrow::UnionArray::field(int) const':
/arrow/cpp/src/arrow/array/array_nested.cc:1360:51: error: 'std::shared_ptr<_Tp> std::atomic_load(const shared_ptr<_Tp>*) [with _Tp = arrow::Array]' is deprecated: use 'std::atomic<std::shared_ptr<T>>' instead [-Werror=deprecated-declarations]
 1360 |   std::shared_ptr<Array> result = std::atomic_load(&boxed_fields_[i]);
      |                                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/shared_ptr_atomic.h:142:5: note: declared here
  142 |     atomic_load(const shared_ptr<_Tp>* __p)
      |     ^~~~~~~~~~~
/arrow/cpp/src/arrow/array/array_nested.cc:1372:22: error: 'void std::atomic_store(shared_ptr<_Tp>*, shared_ptr<_Tp>) [with _Tp = arrow::Array]' is deprecated: use 'std::atomic<std::shared_ptr<T>>' instead [-Werror=deprecated-declarations]
 1372 |     std::atomic_store(&boxed_fields_[i], result);
      |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/shared_ptr_atomic.h:183:5: note: declared here
  183 |     atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
      |     ^~~~~~~~~~~~
cc1plus: all warnings being treated as errors

We can ignore the deprecated-declarations warnings but it may hide other deprecated warnings.

Anyway, this is stuck due to the rebase failure. We can't continue this.

@lidavidm
Copy link
Member

Does it have to be a commit-by-commit rebase? Why not squash first, then rebase and force push?

@BwL1289
Copy link
Author

BwL1289 commented Aug 22, 2025

@kou please see this PR: #47415. I will close this now.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants