arrayfire / arrayfire/arrayfire-rust
[BUG] `af_set_backend` is declared with the wrong parameter width
- Lingua principale
- Rust
- Stelle
- 827
- Fork
- 59
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
[`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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia da src/core/backend.rs:7 e confronta af_set_backend con le dichiarazioni adiacenti nello stesso blocco extern. Controlla include/af/backend.h:24 per confermare il tipo enum C, quindi aggiorna la dichiarazione Rust in modo che corrisponda all’ABI ed esegui i controlli o i test Rust del repository. Il lavoro è completato quando la dichiarazione utilizza la larghezza corretta del parametro e i controlli hanno esito positivo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, rust
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Stato di attività
- Tranquilla
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 88/100