Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion libcudacxx/include/cuda/std/__tuple_dir/tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@

_CCCL_BEGIN_NAMESPACE_CUDA_STD

// Determines whether each element of a tuple_of_iterator_references can actually construct the
// corresponding tuple element. The tuple_of_iterator_references converting constructor below is
// otherwise unconstrained on element convertibility, so is_constructible would report true even for
// ill-formed conversions (e.g. tuple_of_iterator_references<const int&> -> tuple<int&>) and then
// hard-error when the delegating constructor body is instantiated -- which happens during a
// contiguous_iterator concept check on a thrust zip_iterator under GCC 9.
template <class _TupleTypes, class _TupleOfIteratorReferences, class _Indices>
inline constexpr bool __tuple_of_iterator_references_constructible_v = false;

template <class... _Tp, class _TupleOfIteratorReferences, size_t... _Indices>
inline constexpr bool __tuple_of_iterator_references_constructible_v<__tuple_types<_Tp...>,
_TupleOfIteratorReferences,
__tuple_indices<_Indices...>> =
(is_constructible_v<_Tp, decltype(::cuda::std::get<_Indices>(::cuda::std::declval<_TupleOfIteratorReferences>()))>
&& ...);
Comment on lines +56 to +64

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
file="libcudacxx/include/cuda/std/__tuple_dir/tuple.h"
# Show the include block and the trait segment around the reported lines
sed -n '1,120p' "$file"

Repository: NVIDIA/cccl

Length of output: 5434


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check whether forward.h (or other directly-included headers) provides declval
rg -n "declval" libcudacxx/include/cuda/std/__utility/forward.h libcudacxx/include/cuda/std/__utility/move.h libcudacxx/include/cuda/std/__utility/pair.h libcudacxx/include/cuda/std/__utility/swap.h || true

# Show the actual declval declaration/definition location
rg -n "template\s*<.*>\s*.*declval|struct\s*declval|declval\(" libcudacxx/include/cuda/std/__utility/declval.h || true

Repository: NVIDIA/cccl

Length of output: 219


🏁 Script executed:

#!/bin/bash
set -euo pipefail
file="libcudacxx/include/cuda/std/__utility/forward.h"
sed -n '1,140p' "$file"

Repository: NVIDIA/cccl

Length of output: 3404


🏁 Script executed:

#!/bin/bash
set -euo pipefail
file="libcudacxx/include/cuda/std/__tuple_dir/tuple.h"

rg -n "declval\.h" "$file" || true
rg -n "__utility/declval\.h" "$file" || true
rg -n "declval<" "$file" || true

Repository: NVIDIA/cccl

Length of output: 175


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Where is declval.h included from?
rg -n --max-count 50 "cuda/std/__utility/declval\.h" libcudacxx/include/cuda/std || true

# Where is the underlying __declval declared/defined?
rg -n --max-count 50 "__declval" libcudacxx/include/cuda/std/__utility libcudacxx/include/cuda/std || true

Repository: NVIDIA/cccl

Length of output: 6378


suggestion: Add a direct include for declval in libcudacxx/include/cuda/std/__tuple_dir/tuple.h since __tuple_of_iterator_references_constructible_v uses ::cuda::std::declval; the current build relies on a transitive include via tuple_constraints.h.

diff
 `#include` <cuda/std/__utility/forward.h>
+#include <cuda/std/__utility/declval.h>
 `#include` <cuda/std/__utility/move.h>

Source: Coding guidelines


template <class... _Tp>
class _CCCL_TYPE_VISIBILITY_DEFAULT tuple
{
Expand Down Expand Up @@ -225,7 +241,11 @@ class _CCCL_TYPE_VISIBILITY_DEFAULT tuple
// NOLINTBEGIN(modernize-type-traits)
enable_if_t<__is_tuple_of_iterator_references_v<_TupleOfIteratorReferences>, int> = 0,
// NOLINTEND(modernize-type-traits)
enable_if_t<(tuple_size<_TupleOfIteratorReferences>::value == sizeof...(_Tp)), int> = 0>
enable_if_t<(tuple_size<_TupleOfIteratorReferences>::value == sizeof...(_Tp)), int> = 0,
enable_if_t<__tuple_of_iterator_references_constructible_v<__tuple_types<_Tp...>,
_TupleOfIteratorReferences,
__make_tuple_indices_t<sizeof...(_Tp)>>,
int> = 0>
_CCCL_API constexpr tuple(_TupleOfIteratorReferences&& __t)
: tuple(::cuda::std::forward<_TupleOfIteratorReferences>(__t), __make_tuple_indices_t<sizeof...(_Tp)>{})
{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ class tuple_of_iterator_references : public ::cuda::std::tuple<Ts...>

template <
class... Us,
::cuda::std::enable_if_t<is_compatible_tuple_v<::cuda::std::tuple<Us...>, ::cuda::std::tuple<Ts...>>, int> = 0>
::cuda::std::enable_if_t<is_compatible_tuple_v<::cuda::std::tuple<Us...>, ::cuda::std::tuple<Ts...>>, int> = 0,
// Structure compatibility alone is not enough: each held reference must actually convert to the
// requested element, otherwise this operator is selected for ill-formed conversions such as
// tuple_of_iterator_references<const int&> -> tuple<int&>, which then hard-errors in the body
// (e.g. during a contiguous_iterator concept check on a zip_iterator under GCC 9).
::cuda::std::enable_if_t<(::cuda::std::is_convertible_v<Ts, Us> && ...), int> = 0>
_CCCL_HOST_DEVICE constexpr operator ::cuda::std::tuple<Us...>() const
Comment on lines 169 to 177

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="thrust/thrust/iterator/detail/tuple_of_iterator_references.h"

echo "== Includes in $FILE =="
sed -n '1,120p' "$FILE" | nl -ba | sed -n '1,120p'

echo
echo "== Search for is_convertible_v =="
rg -n "::cuda::std::is_convertible_v" "$FILE"

echo
echo "== Show surrounding code for the operator constraints =="
sed -n '140,220p' "$FILE" | nl -ba

Repository: NVIDIA/cccl

Length of output: 195


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="thrust/thrust/iterator/detail/tuple_of_iterator_references.h"

echo "== Top of file (includes) =="
sed -n '1,80p' "$FILE" | cat -n

echo
echo "== Search for is_convertible_v =="
rg -n "::cuda::std::is_convertible_v" "$FILE" || true

echo
echo "== Surrounding code (lines ~140-220) =="
sed -n '140,220p' "$FILE" | cat -n

Repository: NVIDIA/cccl

Length of output: 6797


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Confirm where is_convertible_v is defined
rg -n "is_convertible_v" libcudacxx cuda 2>/dev/null | head -n 50

# 2) Find the specific header that defines it (search by filename + symbol)
fd "is_convertible" -a . 2>/dev/null | head -n 50

# 3) Inspect that header's contents around the definition
H=$(fd "is_convertible.h" -a . 2>/dev/null | head -n 1 || true)
echo "First match for is_convertible.h: $H"
if [ -n "${H:-}" ]; then
  sed -n '1,120p' "$H" | cat -n
  rg -n "is_convertible_v" "$H" || true
fi

# 4) Check whether already-included headers include is_convertible.h
INCLUDES=(
  "cuda/std/__type_traits/common_reference.h"
  "cuda/std/__type_traits/enable_if.h"
)
for inc in "${INCLUDES[@]}"; do
  f=$(fd "$(basename "$inc")" cuda libcudacxx 2>/dev/null | head -n 1 || true)
  echo "Resolved $inc -> $f"
  if [ -n "${f:-}" ]; then
    rg -n "`#include` <cuda/std/__type_traits/is_convertible.h>" "$f" || true
    rg -n "is_convertible" "$f" | head -n 20 || true
  fi
done

Repository: NVIDIA/cccl

Length of output: 7578


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect common_reference.h and enable_if.h for is_convertible includes
for f in \
  "libcudacxx/include/cuda/std/__type_traits/common_reference.h" \
  "libcudacxx/include/cuda/std/__type_traits/enable_if.h" \
  "libcudacxx/include/cuda/std/__tuple_dir/tuple_constraints.h" \
  "libcudacxx/include/cuda/std/__tuple_dir/tuple_element.h" \
  "libcudacxx/include/cuda/std/tuple"; do
  if [ -f "$f" ]; then
    echo "==== $f (top includes) ===="
    sed -n '1,120p' "$f" | cat -n
    echo
    rg -n "`#include` <cuda/std/__type_traits/is_convertible.h>" "$f" || true
    echo
  fi
done

Repository: NVIDIA/cccl

Length of output: 18739


suggestion: tuple_of_iterator_references.h uses ::cuda::std::is_convertible_v in the tuple-conversion SFINAE; add an explicit #include <cuda/std/__type_traits/is_convertible.h> instead of relying on transitive inclusion (currently comes via cuda/std/__type_traits/common_reference.h).

Proposed diff
 `#include` <cuda/std/__type_traits/common_reference.h>
 `#include` <cuda/std/__type_traits/enable_if.h>
+#include <cuda/std/__type_traits/is_convertible.h>
 `#include` <cuda/std/__utility/move.h>

Source: Coding guidelines

{
return __to_tuple<Us...>(typename ::cuda::std::__make_tuple_indices<sizeof...(Ts)>::type{});
Expand Down
Loading