Skip to content

Constants and expressions have diverged on enum-to-float casts. #8230

Closed
@jld

Description

@jld

This program:

enum E { L0 = -1, H0 = 1 }
enum F { L1 = 1, H1 = 0xFFFFFFFFFFFFFFFF }
static C0: float = L0 as float;
static C1: float = H1 as float;
pub fn main() {
        println(fmt!("%?", L0 as float));
        println(fmt!("%?", C0));
        println(fmt!("%?", H1 as float));
        println(fmt!("%?", C1));
}

prints this (on x86_64):

-1
18446744073709552046
-1
18446744073709552046

This seems wrong. It would've been introduced by #8000, I think. Which of the two behaviors seen here is right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions