arrayfire / arrayfire/arrayfire-rust
[BUG] `af_set_backend` is declared with the wrong parameter width
- 主要語言
- Rust
- 星號
- 827
- 分支
- 59
- PR 合併指標
- 30 天內沒有已合併 PR
描述
[`src/core/backend.rs:7`](https://github.com/arrayfire/arrayfire-rust/blob/master/src/core/backend.rs#L7):
```rust
extern "C" {
fn af_set_backend(bknd: u8) -> c_int;
```
The C signature (`include/af/backend.h:24`) is:
```c
AFAPI af_err af_set_backend(const af_backend bknd);
```
`af_backend` is a C enum, i.e. 4-byte `int` under both MSVC and GCC. Declaring the parameter as `u8` is an ABI type mismatch.
In practice it works, because rustc emits `zeroext` for the `u8` argument and the callee reads a clean value from the full register — I checked the IR (`declare noundef i32 @af_set_backend(i8 noundef zeroext)`). So this is as a latent correctness issue rather than an active bug, but it should still be `c_uint` to match the C ABI.
The three neighbouring declarations in the same `extern` block already use `c_uint`/`c_int` correctly.
---
Found by Claude Opus 5.
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
從 src/core/backend.rs:7 開始,將 af_set_backend 與同一 extern 區塊中的相鄰宣告進行比較。檢查 include/af/backend.h:24 以確認 C enum 型別,然後更新 Rust 宣告使其與 ABI 相符,接著執行儲存庫的 Rust 檢查或測試。當該宣告使用正確的參數寬度且檢查通過時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c, rust
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 1/5
- 預估耗時
- 1 小時以內
- 活躍度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 88/100