[libcu++] Guard tuple and pair against dangling references#9622
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughSummary by CodeRabbit
WalkthroughUpdates tuple and pair constructor/assignment selection to distinguish invalid and deleted cases, adds deleted overloads for reference-from-temporary bindings, and expands compile-time tests for tuple and pair constructibility. ChangesReference-from-temporary deletion for pair and tuple
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/from_temporaries.pass.cpp (1)
98-115: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winsuggestion: Add pair-source checks to this helper as well.
This only exercises direct-argument and tuple-source construction. The PR also changes the pair-like constructor path in
pair.h, so a regression there would still pass this file. Addcuda::std::pair<Args..., LvalueTempConverter>and hoststd::pair<...>assertions, including the_CCCL_BUILTIN_REFERENCE_CONSTRUCTS_FROM_TEMPORARYnegative cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 40ec0c9d-0f7a-429f-a368-e527666c5852
📒 Files selected for processing (11)
libcudacxx/include/cuda/std/__optional/optional_ref.hlibcudacxx/include/cuda/std/__tuple_dir/tuple.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.hlibcudacxx/include/cuda/std/__type_traits/reference_constructs_from_temporary.hlibcudacxx/include/cuda/std/__type_traits/sfinae_traits.hlibcudacxx/include/cuda/std/__utility/pair.hlibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpplibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/from_temporaries.pass.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/from_temporaries.pass.cpp
eb40511 to
7694a79
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: cf6c994b-bcf2-4647-b520-9362d1f5ed2c
📒 Files selected for processing (11)
libcudacxx/include/cuda/std/__optional/optional_ref.hlibcudacxx/include/cuda/std/__tuple_dir/tuple.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.hlibcudacxx/include/cuda/std/__type_traits/reference_constructs_from_temporary.hlibcudacxx/include/cuda/std/__type_traits/sfinae_traits.hlibcudacxx/include/cuda/std/__utility/pair.hlibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpplibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/from_temporaries.pass.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/from_temporaries.pass.cpp
✅ Files skipped from review due to trivial changes (3)
- libcudacxx/include/cuda/std/__type_traits/reference_constructs_from_temporary.h
- libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp
- libcudacxx/include/cuda/std/__optional/optional_ref.h
🚧 Files skipped from review as they are similar to previous changes (6)
- libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
- libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpp
- libcudacxx/include/cuda/std/__type_traits/sfinae_traits.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
- libcudacxx/include/cuda/std/__utility/pair.h
7694a79 to
f542cf9
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/from_temporaries.pass.cpp (1)
84-109: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winsuggestion: add
allocator_arg_tconstructibility checks here as well. The stack for this PR saystuplegained deleted allocator-arg overloads in addition to the plain variadic and tuple-like forms, but this file only exercises the latter two. A regression in the allocator-aware branch would currently pass unnoticed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: c84d231e-6010-43f2-a228-c1859a944037
📒 Files selected for processing (11)
libcudacxx/include/cuda/std/__optional/optional_ref.hlibcudacxx/include/cuda/std/__tuple_dir/tuple.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.hlibcudacxx/include/cuda/std/__type_traits/reference_constructs_from_temporary.hlibcudacxx/include/cuda/std/__type_traits/sfinae_traits.hlibcudacxx/include/cuda/std/__utility/pair.hlibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpplibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/from_temporaries.pass.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/from_temporaries.pass.cpp
💤 Files with no reviewable changes (1)
- libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpp
✅ Files skipped from review due to trivial changes (4)
- libcudacxx/include/cuda/std/__type_traits/reference_constructs_from_temporary.h
- libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp
- libcudacxx/include/cuda/std/__optional/optional_ref.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
🚧 Files skipped from review as they are similar to previous changes (4)
- libcudacxx/include/cuda/std/__type_traits/sfinae_traits.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple.h
- libcudacxx/include/cuda/std/__utility/pair.h
f542cf9 to
10106da
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 5897b602-93c9-4a90-ba50-4e0f89960e90
📒 Files selected for processing (11)
libcudacxx/include/cuda/std/__optional/optional_ref.hlibcudacxx/include/cuda/std/__tuple_dir/tuple.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.hlibcudacxx/include/cuda/std/__type_traits/reference_constructs_from_temporary.hlibcudacxx/include/cuda/std/__type_traits/sfinae_traits.hlibcudacxx/include/cuda/std/__utility/pair.hlibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpplibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/from_temporaries.pass.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/from_temporaries.pass.cpp
💤 Files with no reviewable changes (1)
- libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpp
✅ Files skipped from review due to trivial changes (3)
- libcudacxx/include/cuda/std/__type_traits/reference_constructs_from_temporary.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
- libcudacxx/include/cuda/std/__optional/optional_ref.h
🚧 Files skipped from review as they are similar to previous changes (5)
- libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp
- libcudacxx/include/cuda/std/__type_traits/sfinae_traits.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
- libcudacxx/include/cuda/std/__utility/pair.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple.h
| } | ||
|
|
||
| #if defined(_CCCL_BUILTIN_REFERENCE_CONSTRUCTS_FROM_TEMPORARY) | ||
| #ifdef _CCCL_BUILTIN_REFERENCE_CONSTRUCTS_FROM_TEMPORARY |
There was a problem hiding this comment.
-1, I don't like this :D
There was a problem hiding this comment.
I believe there is a clang-tidy rule about that, but I can revert it
…ces` We should not need it anymore. The conversion should do the right thing and it gives GCC grief trying to construct a tuple
10106da to
fe52857
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/from_temporaries.pass.cpp (1)
84-109: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winsuggestion: add
allocator_arg_tconstructibility checks for the deleted-from-temporary cases here. The PR also changes the allocator-aware tuple constructors, but this file only exercises the plain variadic and tuple-like forms, so regressions in that overload set would still pass unnoticed. As per path instructions, libcudacxx reviews should focus on correctness and API stability, and CCCL test sources should use compile-time checks when relevant for compile-time guarantees.Sources: Coding guidelines, Path instructions
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 45d74d9e-6629-46b5-b993-c444211b986a
📒 Files selected for processing (13)
libcudacxx/include/cuda/std/__fwd/tuple.hlibcudacxx/include/cuda/std/__optional/optional_ref.hlibcudacxx/include/cuda/std/__tuple_dir/tuple.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.hlibcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.hlibcudacxx/include/cuda/std/__type_traits/reference_constructs_from_temporary.hlibcudacxx/include/cuda/std/__type_traits/sfinae_traits.hlibcudacxx/include/cuda/std/__utility/pair.hlibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpplibcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/from_temporaries.pass.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpplibcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/from_temporaries.pass.cppthrust/thrust/iterator/detail/tuple_of_iterator_references.h
💤 Files with no reviewable changes (3)
- libcudacxx/include/cuda/std/__fwd/tuple.h
- thrust/thrust/iterator/detail/tuple_of_iterator_references.h
- libcudacxx/test/libcudacxx/std/utilities/utility/pairs/pairs.pair/convert_non_const_copy.cpp
✅ Files skipped from review due to trivial changes (4)
- libcudacxx/include/cuda/std/__type_traits/reference_constructs_from_temporary.h
- libcudacxx/include/cuda/std/__optional/optional_ref.h
- libcudacxx/test/libcudacxx/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp
- libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h
🚧 Files skipped from review as they are similar to previous changes (4)
- libcudacxx/include/cuda/std/__type_traits/sfinae_traits.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple.h
- libcudacxx/include/cuda/std/__utility/pair.h
- libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h
With the new tuple-like constructors we also get deleted constructors if the user tries to store a reference to a temporary
This is an important source of bugs, so we should adopt this too