about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-10-31 16:16:54 +0100
committerRalf Jung <post@ralfj.de>2020-10-31 16:26:06 +0100
commit9f630af93077b276f78701dcd2307d19dccf0e14 (patch)
tree38c13281a2a31c39477048784f303ec2bccc9c00
parented96321e7e32d3c047f204445b849c75f3c63e28 (diff)
downloadrust-9f630af93077b276f78701dcd2307d19dccf0e14.tar.gz
rust-9f630af93077b276f78701dcd2307d19dccf0e14.zip
fix aliasing issue in unix sleep function
-rw-r--r--library/std/src/sys/unix/thread.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs
index fdf114d6df6..f1ab302d30e 100644
--- a/library/std/src/sys/unix/thread.rs
+++ b/library/std/src/sys/unix/thread.rs
@@ -178,7 +178,8 @@ impl Thread {
                     tv_nsec: nsecs,
                 };
                 secs -= ts.tv_sec as u64;
-                if libc::nanosleep(&ts, &mut ts) == -1 {
+                let ts_ptr = &mut ts as *mut _;
+                if libc::nanosleep(ts_ptr, ts_ptr) == -1 {
                     assert_eq!(os::errno(), libc::EINTR);
                     secs += ts.tv_sec as u64;
                     nsecs = ts.tv_nsec;