Skip to content

Calling std::mem::size_of::<T> in a generic constexpr context errors. #45598

Closed
@mystor

Description

@mystor

This code fails to build right now, while it should succeed (as std::mem::size_of::<T> is const):

use std::mem;
use std::marker::PhantomData;
struct U<T>([u8; mem::size_of::<T>()], PhantomData<T>);
fn main() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)I-compiletimeIssue: Problems and improvements with respect to compile times.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions