Rust-GCC / Rust-GCC/gccrs

Repr attributes on ADTs do not have restrictions.

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

Nobody has claimed this yet.

bug good-first-pr
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

According to rust, the valid repr attributes are Rust (default), C, align, packed, transparent, simd, i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize and usize.
But gccrs allows us to use anything as the attribute and this code compiles without any error.

#[repr(this_repr_doesnot_exist)]
enum Starter{
    Bulbasaur,
    Charmander,
    Squirtle,
}

#[repr(!)]
enum Type{
    Grass,
    Fire,
    Water,
}

#[repr(hmmmmmmm)]
struct Stats {
    base_attack: u32,
    base_defense: u32,
    base_speed: u32,
}

fn main(){}

Godbolt: https://godbolt.org/z/f8rhET9ch

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 the Rust repr attribute rules listed in the issue and reproduce the examples using the linked Godbolt case. Trace gccrs handling of repr attributes for enums and structs; done means unsupported forms such as this_repr_doesnot_exist and ! are rejected while the listed valid forms remain accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.