Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Try harder to keep nvrtc happy
Browse files Browse the repository at this point in the history
nvrtc balks at the array constructor of a zero dimensional span as that would be illegal.
  • Loading branch information
miscco committed Nov 11, 2022
1 parent eec0186 commit 4c3bc98
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// <span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// <span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===---------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// <span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===---------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// <cuda/std/span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// <span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ __host__ __device__
constexpr bool testConstexprSpan(Span sp)
{
ASSERT_NOEXCEPT(sp.back());
return &sp.back() == sp.data() + sp.size() - 1;
return &sp.back() == sp.data() + (sp.size() - 1);
}

template <typename Span>
__host__ __device__
void testRuntimeSpan(Span sp)
{
ASSERT_NOEXCEPT(sp.back());
assert(&sp.back() == sp.data() + sp.size() - 1);
assert(&sp.back() == sp.data() + (sp.size() - 1));
}

template <typename Span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// <span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: nvrtc

// <span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// <span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// <span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// UNSUPPORTED: nvrtc

// This test also generates spurious warnings when instantiating std::span
// with a very large extent (like size_t(-2)) -- silence those.
Expand Down
6 changes: 5 additions & 1 deletion include/cuda/std/detail/libcxx/include/span
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,12 @@ public:
{ (void)__count; _LIBCUDACXX_ASSERT(_Extent == __count, "size mismatch in span's constructor (ptr, len)"); }
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 span(pointer __f, pointer __l) : __data{__f}
{ (void)__l; _LIBCUDACXX_ASSERT(_Extent == distance(__f, __l), "size mismatch in span's constructor (ptr, ptr)"); }

#ifdef _LIBCUDACXX_COMPILER_NVRTC
template <size_t _Sz = _Extent, enable_if_t<_Sz != 0, nullptr_t> = nullptr>
_LIBCUDACXX_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr} {}
#else
_LIBCUDACXX_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {}
#endif
template <class _OtherElementType, enable_if_t<
is_convertible<_OtherElementType(*)[], element_type (*)[]>::value, nullptr_t> = nullptr>
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX14
Expand Down

0 comments on commit 4c3bc98

Please sign in to comment.