Skip to content

Compiler allows #[repr(i/u128)] on structs #74082

Closed

Description

@TyPR124

I tried this code:

#[repr(i128)]
#[repr(u128)]
struct Foo;
fn main() {
    println!("{}", std::mem::size_of::<Foo>());
}

I expected to see this happen: compilation failure

Instead, this happened: Compiles, outputs "0"

Meta

rustc --version --verbose:

rustc 1.44.0 (49cae5576 2020-06-01)
binary: rustc
commit-hash: 49cae55760da0a43428eba73abcb659bb70cf2e4
commit-date: 2020-06-01
host: x86_64-pc-windows-msvc
release: 1.44.0
LLVM version: 9.0

Also: playground

This issue has been assigned to @nbdd0121 via this comment.

Activity

  1. added
    A-attributesArea: Attributes (`#[…]`, `#![…]`)
    A-layoutArea: Memory layout of types
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 6, 2020
  2. nbdd0121 commented on Jul 6, 2020

    @nbdd0121
    Member

    Should be a easy fix.

    @rustbot claim

  3. self-assigned this
    on Jul 6, 2020
  4. added a commit that references this issue on Jul 7, 2020
    8cf88d5
  5. added 12 commits that reference this issue on Jul 8, 2020
    022259f
    9220430
    2f5639a
    89aae89
    60213e1
    5fa4d01
    9ff4ab5
    b993139
    1e238fb
    733d3ac
    78f56b7
    8efa197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-layoutArea: Memory layout of typesC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions