rust-lang / rust-lang/rust-bindgen

Incorrect query of whether given comp type is an union in analyses

Open
#1,070 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Analyses like derive_partial_eq_or_partial_ord assumes that if some Comp type is an union and rust target version allows us to use untagged union feature, then that Comp type will be emitted as a rust untagged union.
 
However, this can be not true, because in codegen we still can decide to emit bindgen union instead of rust union.
 
This header should reproduce the case
 

union U4 {
    unsigned derp : 1;
};

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

Start with src/ir/analysis/derive_partial_eq_or_partial_ord.rs and the union handling in src/ir/comp.rs, especially the linked locations. Reproduce the behavior with the header containing union U4 { unsigned derp : 1; }; and trace whether the analysis and codegen make the same union-kind decision. Done means the analysis reflects the union form that codegen will emit.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.