Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(kernels) fix HIPRTC build error ROCm 6/7#9382

Merged
kmaehashi merged 1 commit into
cupy:mainfrom
ROCm:rocm_fix_roc6_7_build_errors
Sep 16, 2025
Merged

feat(kernels) fix HIPRTC build error ROCm 6/7#9382
kmaehashi merged 1 commit into
cupy:mainfrom
ROCm:rocm_fix_roc6_7_build_errors

Conversation

@gpinkert

Copy link
Copy Markdown
Contributor

const bool odd{ _ind.size() & 1 }; triggered a hard compile error under clang/HIPRTC:

non-constant-expression cannot be narrowed from type ‘ptrdiff_t’ to ‘bool’ in initializer list [-Wc++11-narrowing]

C++11 list-initialization ({...}) forbids implicit narrowing conversions. Here _ind.size() returns an integral type (e.g., ptrdiff_t), and brace- initializing a bool from a non-constant integral expression is ill-formed.

Change the expression to produce a real bool:

const bool odd{ (_ind.size() & 1) != 0 };  // (or: _ind.size() % 2 != 0)

This avoids narrowing, keeps brace-init, and restores compatibility with HIPRTC/clang and other strict compilers/flags.

We have also updated kernels to use the default hipRTC compilation standard (14). This enables cepstrum tests on ROCm 7.0

@kmaehashi It would be great to get this backported to v13 since this doesn't break any behavior

`const bool odd{ _ind.size() & 1 };` triggered a hard compile error under
clang/HIPRTC:

> non-constant-expression cannot be narrowed from type ‘ptrdiff\_t’ to ‘bool’ in initializer list \[-Wc++11-narrowing]

C++11 **list-initialization** (`{...}`) forbids implicit narrowing conversions.
Here `_ind.size()` returns an integral type (e.g., `ptrdiff_t`), and brace-
initializing a `bool` from a non-constant integral expression is ill-formed.

Change the expression to produce a real `bool`:

```cpp
const bool odd{ (_ind.size() & 1) != 0 };  // (or: _ind.size() % 2 != 0)
```

This avoids narrowing, keeps brace-init, and restores compatibility with
HIPRTC/clang and other strict compilers/flags.

We have also updated kernels to use the default hipRTC compilation standard (14).
This enables cepstrum tests on ROCm 7.0
@gpinkert gpinkert requested a review from a team as a code owner September 13, 2025 03:31
@kmaehashi kmaehashi self-assigned this Sep 13, 2025
@kmaehashi kmaehashi added cat:enhancement Improvements to existing features prio:medium labels Sep 13, 2025
@kmaehashi

Copy link
Copy Markdown
Member

/test mini

@kmaehashi kmaehashi added this to the v14.0.0a2 milestone Sep 13, 2025
@kmaehashi kmaehashi merged commit f78e78e into cupy:main Sep 16, 2025
71 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:enhancement Improvements to existing features prio:medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants