Skip to content

Repr attributes on ADTs do not have restrictions. #3352

Open
@nobel-sh

Description

@nobel-sh

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions