rust-lang / rust-lang/rust-bindgen

Wrong alignment on vectors

Open
#3,190 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Since vectors are defined with type aliases they have an incorrect alignment.

For example this has an alignment of 8

typedef float float2 __attribute__((vector_size(2 * sizeof(float))));

The generated bindgen code is

pub type float2 = [f32; 2usize];

which has an alignment of 4 instead of the expected 8.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or entry point is named. Start by reproducing the C typedef and inspecting the generated Rust binding's alignment; done means vector aliases preserve the expected 8-byte alignment, with coverage for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.