arrayfire / arrayfire/arrayfire-rust
[BUG] `af_set_backend` is declared with the wrong parameter width
- Linguagem predominante
- Rust
- Estrelas
- 827
- Forks
- 59
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
[`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.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Comece em src/core/backend.rs:7 e compare af_set_backend com as declarações vizinhas no mesmo bloco extern. Verifique include/af/backend.h:24 para confirmar o tipo enum de C, depois atualize a declaração Rust para corresponder à ABI e execute as verificações ou os testes Rust do repositório. Está concluído quando a declaração usa a largura correta do parâmetro e as verificações passam.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- c, rust
- Domínio
- backend
- Tipo de issue
- Bug
- Dificuldade
- 1/5
- Tempo estimado
- Menos de uma hora
- Status de atividade
- Pouca atividade
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 88/100