Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overflow checking failed on #[repr(i64)] enums #23235

Closed
theemathas opened this issue Mar 9, 2015 · 1 comment · Fixed by #23863
Closed

Overflow checking failed on #[repr(i64)] enums #23235

theemathas opened this issue Mar 9, 2015 · 1 comment · Fixed by #23863
Labels
A-type-system Area: Type system

Comments

@theemathas
Copy link
Contributor

Code:

#[repr(i64)]
enum X {
    A = 0x_7FFF_FFFF_FFFF_FFFF,
    B,
}

fn main() {
    println!("{}", X::A as i64);
    println!("{}", X::B as i64);
}

Output:

9223372036854775807
-9223372036854775808

This is the opposite of #23221

@pnkfelix
Copy link
Member

cc #23897

pnkfelix added a commit to pnkfelix/rust that referenced this issue Mar 31, 2015
…values.

Moved such overflow checking into one place (in `rustc::middle::ty`,
since it needs to be run on-demand during `const_eval` in some
scenarios), and revised `rustc_typeck` accordingly.

(Note that we only check for overflow if program did not provide a
discriminant value explicitly.)

Fix rust-lang#23030

Fix rust-lang#23221

Fix rust-lang#23235
pnkfelix added a commit to pnkfelix/rust that referenced this issue Apr 1, 2015
…values.

Moved such overflow checking into one place (in `rustc::middle::ty`,
since it needs to be run on-demand during `const_eval` in some
scenarios), and revised `rustc_typeck` accordingly.

(Note that we only check for overflow if program did not provide a
discriminant value explicitly.)

Fix rust-lang#23030

Fix rust-lang#23221

Fix rust-lang#23235
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 1, 2015
const_eval : add overflow-checking for {`+`, `-`, `*`, `/`, `<<`, `>>`}.

One tricky detail here: There is some duplication of labor between `rustc::middle::const_eval` and `rustc_trans::trans::consts`. It might be good to explore ways to try to factor out the common structure to the two passes (by abstracting over the particular value-representation used in the compile-time interpreter).

----

Update: Rebased atop rust-lang#23841

Fix rust-lang#22531

Fix rust-lang#23030

Fix rust-lang#23221

Fix rust-lang#23235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
3 participants