Skip to content

Commit 2c19856

Browse files
committed
rt: Fix alignment in debug_opaque
1 parent c22d0af commit 2c19856

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/rt/rust_builtin.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,12 @@ 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+
// Account for alignment. `front` may not indeed be the
245+
// front byte of the passed-in argument
246+
if (((uintptr_t)front % t->align) != 0) {
247+
front = (uint8_t *)align_to((uintptr_t)front, (size_t)t->align);
248+
}
244249
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-
251250
LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, *front);
252251
}
253252
}

0 commit comments

Comments
 (0)