Skip to content

Const sanity checks skips uninhabited arrays #54751

@RalfJung

Description

@RalfJung
Member

The following should be stopped by the const sanity check:

#![feature(never_type, const_transmute)]

use std::mem;

const TEST: [!; 1] = unsafe { mem::transmute(()) };

But it is not.

The issue is that the sanity check calls is_zst() to skip arrays that could be immediate, but some of those arrays are uninhabited...

Cc @oli-obk

Activity

oli-obk

oli-obk commented on Oct 2, 2018

@oli-obk
Contributor

lolwat. That should not even pass WF checks, right? Statics and constants should not be allowed to have uninhabited types.

RalfJung

RalfJung commented on Oct 2, 2018

@RalfJung
MemberAuthor

That's just a bandaid though, WF checks won't catch the same thing wrapped in an Option (and Some).

self-assigned this
on Oct 2, 2018
RalfJung

RalfJung commented on Oct 2, 2018

@RalfJung
MemberAuthor

I will fix this as part of my work for preparing validation for miri usage.

added a commit that references this issue on Oct 2, 2018
5c450de
added a commit that references this issue on Oct 4, 2018
added a commit that references this issue on Oct 9, 2018
0a2fae6
added a commit that references this issue on Oct 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @RalfJung@oli-obk

    Issue actions

      Const sanity checks skips uninhabited arrays · Issue #54751 · rust-lang/rust