Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT __basic_any : __basic_any_base<_Interface>
return __get_vptr() != nullptr;
}

// GCC cannot prove __query_interface returns non-null for __iunknown (the invariant guarantees it). This
// affects the reset() and type() methods.
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_GCC("-Wnull-dereference")

//! @brief Resets the `__basic_any` object to an empty state.
//! @post `has_value() == false`
_CCCL_API void reset() noexcept
Expand All @@ -367,6 +372,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT __basic_any : __basic_any_base<_Interface>
}
return _CCCL_TYPEID(void);
}
_CCCL_DIAG_POP

//! @brief Returns a reference to a type_info object representing the type of
//! the dynamic interface.
Expand Down
5 changes: 5 additions & 0 deletions libcudacxx/include/cuda/__utility/__basic_any/rtti.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ struct __rtti_ex : __rtti
__base_info __base_vptr_array[_NbrInterfaces];
};

// GCC cannot prove __query_interface(__iunknown()) is non-null when inlined
// (the __iunknown interface is always registered; the design guarantees non-null here)
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_GCC("-Wnull-dereference")
//!
//! __try_vptr_cast
//!
Expand Down Expand Up @@ -228,6 +232,7 @@ template <class _SrcInterface, class _DstInterface>
return rtti->__query_interface(_DstInterface());
}
}
_CCCL_DIAG_POP

template <class _SrcInterface, class _DstInterface>
[[nodiscard]] _CCCL_API auto __vptr_cast(__vptr_for<_SrcInterface> __src_vptr) //
Expand Down
5 changes: 5 additions & 0 deletions libcudacxx/include/cuda/__utility/__basic_any/virtcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ inline constexpr bool __valid_virtcall = sizeof...(_Interface) == 1;
template <auto _Mbr, class _Interface>
inline constexpr bool __valid_virtcall<_Mbr, __ireference<_Interface const>> = __virtual_fn<_Mbr>::__const_fn;

// GCC cannot prove __vptr is non-null (the type-erasure invariant guarantees it)
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_GCC("-Wnull-dereference")
template <auto _Mbr, class _Interface, class _Super, class _Self, class... _Args>
_CCCL_API auto __virtcall(_Self* __self, _Args&&... __args) //
noexcept(__virtual_fn<_Mbr>::__nothrow_fn) //
Expand All @@ -114,8 +117,10 @@ _CCCL_API auto __virtcall(_Self* __self, _Args&&... __args) //
auto* __obj = __basic_any_access::__get_optr(*__self);
// map the member function pointer to the correct one if necessary
using __virtual_fn_t = __virtual_fn_for<_Mbr, _Interface, _Super>;

return __vptr->__virtual_fn_t::__fn_(__obj, static_cast<_Args&&>(__args)...);
}
_CCCL_DIAG_POP

_CCCL_TEMPLATE(auto _Mbr, template <class...> class _Interface, class _Super, class... _Args)
_CCCL_REQUIRES(__valid_virtcall<_Mbr, _Super>)
Expand Down
6 changes: 4 additions & 2 deletions libcudacxx/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ if ("${CMAKE_CUDA_COMPILER_ID}" STREQUAL "NVIDIA")
-Wall
-Werror
all-warnings
-Wnull-dereference
-Wno-deprecated-gpu-targets
)
endif()
Expand All @@ -66,19 +67,20 @@ elseif ("${CMAKE_CUDA_COMPILER_ID}" STREQUAL "Clang")
headertest_warning_levels_device
-Wall
-Werror
-Wnull-dereference
-Wno-unknown-cuda-version
-Xclang=-fcuda-allow-variadic-functions
)
# If the CMAKE_CUDA_COMPILER is unknown, try to use gcc style warnings
else()
set(headertest_warning_levels_device -Wall -Werror)
set(headertest_warning_levels_device -Wall -Werror -Wnull-dereference)
endif()

# Set raw host/device warnings
if (MSVC)
set(headertest_warning_levels_host /W4 /WX)
else()
set(headertest_warning_levels_host -Wall -Werror)
set(headertest_warning_levels_host -Wall -Werror -Wnull-dereference)
endif()

# Enable building the nvrtcc project if NVRTC is enabled
Expand Down