diff --git a/reference/src/SUMMARY.md b/reference/src/SUMMARY.md index 3dcb465b..bf52b9ee 100644 --- a/reference/src/SUMMARY.md +++ b/reference/src/SUMMARY.md @@ -11,5 +11,7 @@ - [Function pointers](./layout/function-pointers.md) - [Arrays and Slices](./layout/arrays-and-slices.md) - [Packed SIMD vectors](./layout/packed-simd-vectors.md) +- [Validity](./validity.md) + - [Unions](./validity/unions.md) - [Optimizations](./optimizations.md) - [Return value optimization](./optimizations/return_value_optimization.md) diff --git a/reference/src/validity/unions.md b/reference/src/validity/unions.md new file mode 100644 index 00000000..86c95478 --- /dev/null +++ b/reference/src/validity/unions.md @@ -0,0 +1,13 @@ +# Validity of unions + +**Disclaimer**: This chapter is a work-in-progress. What's contained here +represents the consensus from issue [#73]. The statements in here are not (yet) +"guaranteed" not to change until an RFC ratifies them. + +## Validity of unions with zero-sized fields + +A union containing a zero-sized field can contain any bit pattern. An example of such +an union is [`MaybeUninit`]. + +[#73]: https://github.com/rust-lang/unsafe-code-guidelines/issues/73 +[`MaybeUninit`]: https://doc.rust-lang.org/std/mem/union.MaybeUninit.html