Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uparithmetic-overflow checks during const-eval #23863
Conversation
rust-highfive
assigned
alexcrichton
Mar 30, 2015
This comment has been minimized.
This comment has been minimized.
|
(rust_highfive has picked a reviewer for you, use r? to override) |
pnkfelix
changed the title
Arith oflo const eval
arithmetic-overflow checks during const-eval
Mar 30, 2015
This comment has been minimized.
This comment has been minimized.
|
cc @eddyb (actually, I'd be happy to take a review from eddyb) Also, eddyb: You may be concerned about collisions here with your own const-fn work. Feel free to recommend some ordering on how the two PR's land, or suggest some other strategy to avoid unnecessary rebasing effort. |
This comment has been minimized.
This comment has been minimized.
rust-highfive
assigned
nikomatsakis
and unassigned
alexcrichton
Mar 30, 2015
This comment has been minimized.
This comment has been minimized.
|
As for the checks in trans: I did something else for div/rem: @nikomatsakis I wonder if recording "obligations" on constant evaluation would make sense - like |
eddyb
reviewed
Mar 30, 2015
| if !oflo { Ok(const_uint(ret)) } else { signal!(e, SubuWithOverflow(a, b)) } | ||
|
|
||
| pub_fn_checked_op!{ const_int_checked_add(a: i64, b: i64,.. IntTy) { | ||
| int_arith_body overflowing_add const_int AddiWithOverflow(a, b) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
pnkfelix
Mar 30, 2015
Author
Member
yeah it was so that the operator name (e.g. "add") would line up in both the method name and in the operator invocation.
Maybe I would have been better off using some well-placed calls to stringify!...
This comment has been minimized.
This comment has been minimized.
|
r+ modulo the FIXME |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Should we open a discussion about the interactions between I personally prefer checking somewhere higher than It works for this PR, and it's not enough to stop it from merging (we need those checks in beta), but I hope we can find a cleaner solution. |
pnkfelix
referenced this pull request
Mar 31, 2015
Closed
const_eval::cast_const should use target's int/uint types for isize/usize #23890
This comment has been minimized.
This comment has been minimized.
|
@bors r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
I just made this post on internals: http://internals.rust-lang.org/t/removing-const-eval-duplication-of-labor-between-librustc-and-librustc-trans/1786 so we can continue that conversation in a focused fashion there. |
This comment has been minimized.
This comment has been minimized.
pnkfelix
referenced this pull request
Mar 31, 2015
Closed
repr-type specific oflo checks for enum discrim values. #23841
pnkfelix
force-pushed the
pnkfelix:arith-oflo-const-eval
branch
2 times, most recently
to
7506c3d
Mar 31, 2015
aturon
referenced this pull request
Mar 31, 2015
Closed
Tracking issue for Integer Overflow (RFC 560) #22020
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
annoying: the error messages on some of my tests are different for 64-bit compile versus a cross-compiling 64-bit host/32-bit target. :( Update: Well, being forced to fix this may yield an overall code cleanup. :) |
pnkfelix
added some commits
Mar 27, 2015
pnkfelix
added some commits
Mar 27, 2015
pnkfelix
force-pushed the
pnkfelix:arith-oflo-const-eval
branch
from
4298dc5
to
2a9de1d
Apr 1, 2015
This comment has been minimized.
This comment has been minimized.
|
r=nikomatsakis ; @alexcrichton says he will merge into next rollup. |
This comment has been minimized.
This comment has been minimized.
|
@bors: r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this pull request
Apr 1, 2015
bors
merged commit 2a9de1d
into
rust-lang:master
Apr 1, 2015
1 check passed
This comment has been minimized.
This comment has been minimized.
|
I think this caused #23968: |
pnkfelix commentedMar 30, 2015
const_eval : add overflow-checking for {
+,-,*,/,<<,>>}.One tricky detail here: There is some duplication of labor between
rustc::middle::const_evalandrustc_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 #23841
Fix #22531
Fix #23030
Fix #23221
Fix #23235