From 98122d3ea0728e715cf12df426946b21a61b511e Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 11 May 2023 18:35:20 -0400 Subject: [PATCH] Support gcc 12 as the C++ compiler (#13316) Corrects compilation issues found by gcc 12 and the new warnings it provides. Three major classes of issues was found: - incorrect lambda captures of the wrong container for the iterators being used - incorrect implicit conversions - warnings generated by using std::transform and std::initializer_lists Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Bradley Dice (https://github.com/bdice) - David Wendt (https://github.com/davidwendt) - Nghia Truong (https://github.com/ttnghia) - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/cudf/pull/13316 --- cpp/cmake/thirdparty/patches/nvbench_override.json | 5 +++++ cpp/include/cudf_test/iterator_utilities.hpp | 8 +++++--- cpp/include/cudf_test/type_lists.hpp | 14 ++++++++------ cpp/src/io/json/json_column.cu | 6 +++--- cpp/src/io/json/nested_json_gpu.cu | 7 ++++--- cpp/tests/io/json_test.cpp | 2 +- cpp/tests/scalar/scalar_test.cpp | 4 ++-- 7 files changed, 28 insertions(+), 18 deletions(-) diff --git a/cpp/cmake/thirdparty/patches/nvbench_override.json b/cpp/cmake/thirdparty/patches/nvbench_override.json index 7be868081b6..d5df222ae37 100644 --- a/cpp/cmake/thirdparty/patches/nvbench_override.json +++ b/cpp/cmake/thirdparty/patches/nvbench_override.json @@ -12,6 +12,11 @@ "file" : "nvbench/use_existing_fmt.diff", "issue" : "Fix add support for using an existing fmt [https://github.com/NVIDIA/nvbench/pull/125]", "fixed_in" : "" + }, + { + "file" : "nvbench/public_fmt_dep_in_conda.diff", + "issue" : "Propagate fmt requirement in conda envs [https://github.com/NVIDIA/nvbench/pull/127]", + "fixed_in" : "" } ] } diff --git a/cpp/include/cudf_test/iterator_utilities.hpp b/cpp/include/cudf_test/iterator_utilities.hpp index c2c6b3ae83d..10f6e77d889 100644 --- a/cpp/include/cudf_test/iterator_utilities.hpp +++ b/cpp/include/cudf_test/iterator_utilities.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,6 +121,9 @@ template * The returned iterator yields `false` (to mark `null`) at the indices corresponding to the * pointers having `nullptr` values and `true` for the remaining indices. * + * @note The input vector is referenced by the transform iterator, so the + * lifespan must be just as long as the iterator. + * * @tparam T the data type * @param ptrs The data pointers for which the validity iterator is computed * @return auto Validity iterator @@ -128,8 +131,7 @@ template template [[maybe_unused]] static auto nulls_from_nullptrs(std::vector const& ptrs) { - // The vector `indices` is copied into the lambda as it can be destroyed at the caller site. - return thrust::make_transform_iterator(ptrs.begin(), [ptrs](auto ptr) { return ptr != nullptr; }); + return thrust::make_transform_iterator(ptrs.begin(), [](auto ptr) { return ptr != nullptr; }); } } // namespace iterators diff --git a/cpp/include/cudf_test/type_lists.hpp b/cpp/include/cudf_test/type_lists.hpp index 6ea4311c8cb..2404cf0d134 100644 --- a/cpp/include/cudf_test/type_lists.hpp +++ b/cpp/include/cudf_test/type_lists.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,11 +84,13 @@ std::enable_if_t() && !cudf::is_timestamp_t> make_type_param_vector(std::initializer_list const& init_list) { - thrust::host_vector vec(init_list.size()); - std::transform(std::cbegin(init_list), std::cend(init_list), std::begin(vec), [](auto const& e) { - if constexpr (std::is_unsigned_v) { return static_cast(std::abs(e)); } - return static_cast(e); - }); + std::vector input{init_list}; + std::vector vec(init_list.size()); + std::transform( + std::cbegin(input), std::cend(input), std::begin(vec), [](auto const& e) -> TypeParam { + if constexpr (std::is_unsigned_v) { return static_cast(std::abs(e)); } + return static_cast(e); + }); return vec; } diff --git a/cpp/src/io/json/json_column.cu b/cpp/src/io/json/json_column.cu index 65c93105304..0fdcd33ada4 100644 --- a/cpp/src/io/json/json_column.cu +++ b/cpp/src/io/json/json_column.cu @@ -813,10 +813,10 @@ std::pair, std::vector> device_json_co // For string columns return ["offsets", "char"] schema if (target_type.id() == type_id::STRING) { - return {std::move(col), {{"offsets"}, {"chars"}}}; + return {std::move(col), std::vector{{"offsets"}, {"chars"}}}; } // Non-string leaf-columns (e.g., numeric) do not have child columns in the schema - return {std::move(col), {}}; + return {std::move(col), std::vector{}}; } case json_col_t::StructColumn: { std::vector> child_columns; @@ -860,7 +860,7 @@ std::pair, std::vector> device_json_co data_type{type_id::INT8}, 0, rmm::device_buffer{0, stream, mr}), - {}} + std::vector{}} : device_json_column_to_cudf_column( json_col.child_columns.begin()->second, d_input, diff --git a/cpp/src/io/json/nested_json_gpu.cu b/cpp/src/io/json/nested_json_gpu.cu index c29bf2f8866..d8ca0411910 100644 --- a/cpp/src/io/json/nested_json_gpu.cu +++ b/cpp/src/io/json/nested_json_gpu.cu @@ -1678,11 +1678,11 @@ std::pair, std::vector> json_column_to // For string columns return ["offsets", "char"] schema if (target_type.id() == type_id::STRING) { - return {std::move(col), {{"offsets"}, {"chars"}}}; + return {std::move(col), std::vector{{"offsets"}, {"chars"}}}; } // Non-string leaf-columns (e.g., numeric) do not have child columns in the schema else { - return {std::move(col), {}}; + return {std::move(col), std::vector{}}; } break; } @@ -1724,7 +1724,8 @@ std::pair, std::vector> json_column_to auto [child_column, names] = json_col.child_columns.empty() ? std::pair, - std::vector>{std::make_unique(), {}} + std::vector>{std::make_unique(), + std::vector{}} : json_column_to_cudf_column(json_col.child_columns.begin()->second, d_input, options, diff --git a/cpp/tests/io/json_test.cpp b/cpp/tests/io/json_test.cpp index 9bf16ecca6b..cd067cce928 100644 --- a/cpp/tests/io/json_test.cpp +++ b/cpp/tests/io/json_test.cpp @@ -1568,7 +1568,7 @@ TEST_P(JsonReaderParamTest, JsonDtypeParsing) auto make_validity = [](std::vector const& validity) { return cudf::detail::make_counting_transform_iterator( - 0, [=](auto i) -> bool { return static_cast(validity[i]); }); + 0, [&](auto i) -> bool { return static_cast(validity[i]); }); }; constexpr int int_ignore{}; diff --git a/cpp/tests/scalar/scalar_test.cpp b/cpp/tests/scalar/scalar_test.cpp index 9c70fc364c7..d2f2b5d6a2e 100644 --- a/cpp/tests/scalar/scalar_test.cpp +++ b/cpp/tests/scalar/scalar_test.cpp @@ -33,7 +33,7 @@ TYPED_TEST_SUITE(TypedScalarTestWithoutFixedPoint, cudf::test::FixedWidthTypesWi TYPED_TEST(TypedScalarTest, DefaultValidity) { using Type = cudf::device_storage_type_t; - Type value = cudf::test::make_type_param_scalar(7); + Type value = static_cast(cudf::test::make_type_param_scalar(7)); cudf::scalar_type_t s(value); EXPECT_TRUE(s.is_valid()); @@ -71,7 +71,7 @@ TYPED_TEST(TypedScalarTestWithoutFixedPoint, SetNull) TYPED_TEST(TypedScalarTest, CopyConstructor) { using Type = cudf::device_storage_type_t; - Type value = cudf::test::make_type_param_scalar(8); + Type value = static_cast(cudf::test::make_type_param_scalar(8)); cudf::scalar_type_t s(value); auto s2 = s;