Skip to content

Commit

Permalink
ARROW-14800: [C++] Disambiguate std::launder on MSVC with C++17 enabled
Browse files Browse the repository at this point in the history
Closes #11806 from pitrou/ARROW-14800-launder-disambiguate

Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Krisztián Szűcs <szucs.krisztian@gmail.com>
  • Loading branch information
pitrou authored and kszucs committed Dec 1, 2021
1 parent 2233ac5 commit fe9d031
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ jobs:
ci/scripts/cpp_test.sh $(pwd) $(pwd)/build
windows:
name: AMD64 ${{ matrix.name }} C++
name: AMD64 ${{ matrix.name }} C++17
runs-on: ${{ matrix.os }}
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
timeout-minutes: 45
Expand All @@ -197,6 +197,7 @@ jobs:
ARROW_BUILD_SHARED: ON
ARROW_BUILD_STATIC: OFF
ARROW_BUILD_TESTS: ON
ARROW_CXXFLAGS: "/std:c++17"
ARROW_DATASET: ON
ARROW_FLIGHT: OFF
ARROW_HDFS: ON
Expand All @@ -218,7 +219,7 @@ jobs:
CMAKE_INSTALL_LIBDIR: bin
CMAKE_INSTALL_PREFIX: /usr
CMAKE_UNITY_BUILD: ON
NPROC: 2
NPROC: 3
steps:
- name: Disable Crash Dialogs
run: |
Expand Down
9 changes: 6 additions & 3 deletions cpp/src/arrow/util/aligned_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ class AlignedStorage {
static constexpr bool can_memcpy = std::is_trivial<T>::value;

#if __cpp_constexpr >= 201304L // non-const constexpr
constexpr T* get() noexcept { return launder(reinterpret_cast<T*>(&data_)); }
constexpr T* get() noexcept {
return arrow::internal::launder(reinterpret_cast<T*>(&data_));
}
#else
T* get() noexcept { return launder(reinterpret_cast<T*>(&data_)); }
T* get() noexcept { return arrow::internal::launder(reinterpret_cast<T*>(&data_)); }
#endif

constexpr const T* get() const noexcept {
return launder(reinterpret_cast<const T*>(&data_));
// Use fully qualified name to avoid ambiguities with MSVC (ARROW-14800)
return arrow::internal::launder(reinterpret_cast<const T*>(&data_));
}

void destroy() noexcept {
Expand Down

0 comments on commit fe9d031

Please sign in to comment.