arrayfire / arrayfire/arrayfire-rust

[BUG] `af_set_backend` is declared with the wrong parameter width

Offen Anfängerfreundlich
#388 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Bug
Vorherrschende Sprache
Rust
Sterne
827
Forks
59
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

[`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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start in src/core/backend.rs:7 and compare af_set_backend with the neighboring declarations in the same extern block. Check include/af/backend.h:24 to confirm the C enum type, update the Rust declaration to match the ABI, then run the repository's Rust checks or tests. Done means the declaration uses the correct parameter width and the checks pass.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, rust
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
1/5
Geschätzter Aufwand
Unter einer Stunde
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
88/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.