2025-07-01 21:46:28 +05:00
|
|
|
//! Validates the correct behavior of writing a `bool` value using `std::ptr::write`.
|
|
|
|
|
//!
|
|
|
|
|
//! This test addresses historical concerns regarding the internal representation of `bool`
|
|
|
|
|
//! (e.g., as `i1` in LLVM versus its byte-aligned memory layout) and checks that
|
|
|
|
|
//! `ptr::write` correctly handles this type without issues, confirming its memory
|
|
|
|
|
//! behavior is as expected.
|
|
|
|
|
|
2019-07-27 00:54:25 +03:00
|
|
|
//@ run-pass
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2014-10-14 23:05:01 -07:00
|
|
|
use std::ptr;
|
2013-05-24 19:35:29 -07:00
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2013-05-24 19:35:29 -07:00
|
|
|
unsafe {
|
|
|
|
|
let mut x: bool = false;
|
|
|
|
|
// this line breaks it
|
2014-10-14 23:05:01 -07:00
|
|
|
ptr::write(&mut x, false);
|
2013-05-24 19:35:29 -07:00
|
|
|
}
|
2012-12-05 20:21:29 -08:00
|
|
|
}
|