NVIDIA / NVIDIA/cccl

[BUG]: _LIBCUDACXX_DEBUG_ASSERT doesn't work in constexpr contexts in all compilers

Open
#422 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.5k
Forks
486
Avg merge
2d 6h
Merged PRs (30d)
295

Description

### Is this a duplicate?

- [X] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)

### Type of Bug

Something else

### Component

libcu++

### Describe the bug

It is currently not possible to use `_LIBCUDACXX_DEBUG_ASSERT` in constexpr contexts on all platforms.

This has lead to discussion:

https://github.com/NVIDIA/cccl/pull/358/files/4b9f0b8bb969646d6d877321e3d5de9da75bf833#r1318479854

### How to Reproduce

https://cuda.godbolt.org/z/Y1nT8E5f1

```
#include

// This actually compiles fine, but apparently not with GCC 6 as host compiler.

# define _LIBCUDACXX_DEBUG_ASSERT(x, m) _LIBCUDACXX_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)

__device__ constexpr int f(int count) {
_LIBCUDACXX_DEBUG_ASSERT(count >= 0, "");
return count;
}
```

### Expected behavior

We should have a way to use the debug asserts in constexpr contexts. Whether that is disabled on older host compilers or not doesn't matter imho.

### Reproduction link

_No response_

### Operating System

_No response_

### nvidia-smi output

_No response_

### NVCC version

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.