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 upPrimitive binops are translated wrong when the LHS is mutated #27054
Comments
arielb1
added
the
I-wrong
label
Jul 15, 2015
This comment has been minimized.
This comment has been minimized.
|
Looks like this is specifically an issue with the implementation of expr::trans_binary: Rust semantics say the value is supposed to be immediately loaded into a temporary, but expr::trans just returns a pointer into the Box. |
This comment has been minimized.
This comment has been minimized.
|
triage: I-nominated |
rust-highfive
added
the
I-nominated
label
Aug 13, 2015
alexcrichton
added
the
T-compiler
label
Aug 13, 2015
This comment has been minimized.
This comment has been minimized.
|
Some more testcases: fn main() {
let x = Box::new(0);
let mut y = 0;
*{ drop(x); let _ = Box::new(main); &mut y } = *x;
println!("{}", y);
}#[derive(Debug, Copy, Clone)]
struct CoolInt(i32);
impl std::ops::Add<CoolInt> for CoolInt {
type Output = CoolInt;
fn add(self, other: CoolInt) -> CoolInt { CoolInt(self.0 + other.0) }
}
fn main() {
let x = Box::new(CoolInt(0));
let mut y = CoolInt(0);
println!("{:?}", *x + *{ drop(x); let _ = Box::new(main); &mut y });
}struct R { x: i32, y: i32, z: i32 }
fn main() {
let x = Box::new(0);
let r = R { x: 0, y: 0, z: 0 };
let r = R { x: *x, y: { drop(x); let _ = Box::new(main); 0 }, ..r};
println!("{} {} {}", r.x, r.y, r.z);
}fn main() {
let x = Box::new(0);
let mut y = 0;
*{ drop(x); &mut y } += *x;
println!("{}", y);
} |
This comment has been minimized.
This comment has been minimized.
|
Your augmented assignment example is actually an order-of-operations mismatch - a different issue. |
arielb1
referenced
this issue
in nikomatsakis/rust
Aug 18, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Related to #28160 |
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium |
rust-highfive
added
P-medium
and removed
I-nominated
labels
Sep 17, 2015
This comment has been minimized.
This comment has been minimized.
|
Looks like this is fixed by MIR. |
This comment has been minimized.
This comment has been minimized.
|
Verified as fixed by MIR, marking as E-needstest. Edit: Well, verified as fixed. No idea if it was by MIR, though. |
Mark-Simulacrum
added
the
E-needstest
label
May 6, 2017
This comment has been minimized.
This comment has been minimized.
|
Yes, MIR would've fixed this. |
Mark-Simulacrum
added
C-bug
and removed
I-wrong
labels
Jul 22, 2017
varkor
added a commit
to varkor/rust
that referenced
this issue
Feb 25, 2019
varkor
added a commit
to varkor/rust
that referenced
this issue
Feb 25, 2019
varkor
added a commit
to varkor/rust
that referenced
this issue
Feb 26, 2019
Centril
added a commit
to Centril/rust
that referenced
this issue
Feb 27, 2019
varkor
added a commit
to varkor/rust
that referenced
this issue
Feb 27, 2019
pietroalbini
added a commit
to pietroalbini/rust
that referenced
this issue
Mar 1, 2019
kennytm
added a commit
to kennytm/rust
that referenced
this issue
Mar 2, 2019
Centril
added a commit
to Centril/rust
that referenced
this issue
Mar 9, 2019
Centril
added a commit
to Centril/rust
that referenced
this issue
Mar 9, 2019
bors
added a commit
that referenced
this issue
Mar 10, 2019
varkor
added a commit
to varkor/rust
that referenced
this issue
Mar 11, 2019
bors
added a commit
that referenced
this issue
Mar 12, 2019
varkor
added a commit
to varkor/rust
that referenced
this issue
Mar 12, 2019
pietroalbini
added a commit
to pietroalbini/rust
that referenced
this issue
Mar 12, 2019
bors
added a commit
that referenced
this issue
Mar 12, 2019
bors
closed this
in
#58743
Mar 13, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
arielb1 commentedJul 15, 2015
STR
Expected Results
If this code compiles, it should print
0.Actual Results
Garbage is printed (the address of
main, in fact).