Skip to content

Commit c22d0af

Browse files
committed
rt: take into account alignment for debug_opaque. Closes rust-lang#2667
1 parent d67e144 commit c22d0af

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/rt/rust_builtin.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,13 @@ debug_opaque(type_desc *t, uint8_t *front) {
241241
rust_task *task = rust_get_current_task();
242242
LOG(task, stdlib, "debug_opaque");
243243
debug_tydesc_helper(t);
244-
// FIXME (#2667) may want to actually account for alignment.
245-
// `front` may not indeed be the front byte of the passed-in
246-
// argument.
247244
for (uintptr_t i = 0; i < t->size; ++front, ++i) {
245+
246+
// Account for alignment. `front` may not indeed be the
247+
// front byte of the passed-in argument
248+
if (((uintptr_t)front % t->align) != 0)
249+
front = (uint8_t *)align_to((uintptr_t)front, (size_t)t->align);
250+
248251
LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, *front);
249252
}
250253
}

0 commit comments

Comments
 (0)