about summary refs log tree commit diff
path: root/tests/ui/ptr_ops/ptr-write-bool-representation.rs
blob: 3dfc3e51ab298f6cedd4728a17d5cc8557ba61e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! 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.

//@ run-pass

use std::ptr;

pub fn main() {
    unsafe {
        let mut x: bool = false;
        // this line breaks it
        ptr::write(&mut x, false);
    }
}