From fa19d3c974dae37cf335781300d0e4791be0d87c Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 7 Jun 2026 02:20:47 +0200 Subject: [PATCH] emit: fix aliasing-breaking pointer dereference via union emit.c:186:50: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] Bug: https://bugs.gentoo.org/976975 --- emit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/emit.c b/emit.c index 45a6e5a..0abb3f2 100644 --- a/emit.c +++ b/emit.c @@ -160,6 +160,7 @@ emitfin(FILE *f, char *sec[3]) Asmbits *b; int lg, i; union { int32_t i; float f; } u; + union { int64_t i; double f; } uu; if (!stash) return; @@ -178,13 +179,13 @@ emitfin(FILE *f, char *sec[3]) "\n\t.quad %"PRId64 "\n\t.quad 0\n\n", (int64_t)b->n); - else if (lg == 3) + else if (lg == 3) { + uu.i = b->n; fprintf(f, "\n\t.quad %"PRId64 " /* %f */\n\n", - (int64_t)b->n, - *(double *)&b->n); - else if (lg == 2) { + uu.i, uu.f); + } else if (lg == 2) { u.i = b->n; fprintf(f, "\n\t.int %"PRId32