File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -411,7 +411,11 @@ impl<T> Vec<T> {
411
411
///
412
412
/// Violating these may cause problems like corrupting the allocator's
413
413
/// internal data structures. For example it is **not** safe
414
- /// to build a `Vec<u8>` from a pointer to a C `char` array and a `size_t`.
414
+ /// to build a `Vec<u8>` from a pointer to a C `char` array with length `size_t`.
415
+ /// It's also not safe to build one from a `Vec<u16>` and its length, because
416
+ /// the allocator cares about the alignment, and these two types have different
417
+ /// alignments. The buffer was allocated with alignment 2 (for `u16`), but after
418
+ /// turning it into a `Vec<u8>` it'll be deallocated with alignment 1.
415
419
///
416
420
/// The ownership of `ptr` is effectively transferred to the
417
421
/// `Vec<T>` which may then deallocate, reallocate or change the
You can’t perform that action at this time.
0 commit comments