diff --git a/src/Zcu.zig b/src/Zcu.zig index d26417c8f7..523c14251e 100644 --- a/src/Zcu.zig +++ b/src/Zcu.zig @@ -2932,6 +2932,12 @@ pub fn saveZirCache(gpa: Allocator, cache_file: std.fs.File, stat: std.fs.File.S const as_struct: *const HackDataLayout = @ptrCast(data); safety_buffer[i] = as_struct.data; } + // Union variants smaller than 8 bytes leave padding uninitialised. + // The copy above propagates those V-bits into safety_buffer, so + // valgrind flags the subsequent pwritev. The padding is never + // interpreted on read-back (the tag array determines the active + // variant), so tell valgrind the buffer contents are intentional. + std.valgrind.memcheck.makeMemDefined(std.mem.sliceAsBytes(safety_buffer)); } const header: Zir.Header = .{