logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0001-Fix-aliasing-violation.patch (1137B)


  1. From 70d0e4d5052565eb7124d00542249c0059c26378 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Mon, 28 Apr 2025 22:44:49 -0700
  4. Subject: [PATCH] Fix aliasing violation
  5. ---
  6. emit.c | 14 +++++++-------
  7. 1 file changed, 7 insertions(+), 7 deletions(-)
  8. diff --git a/emit.c b/emit.c
  9. index 04837a5..19fd56d 100644
  10. --- a/emit.c
  11. +++ b/emit.c
  12. @@ -155,7 +155,7 @@ emitfin(FILE *f, char *sec[3])
  13. {
  14. Asmbits *b;
  15. int lg, i;
  16. - union { int32_t i; float f; } u;
  17. + union { int32_t i32; float f32; int64_t i64; double f64; } u;
  18. if (!stash)
  19. return;
  20. @@ -174,18 +174,18 @@ emitfin(FILE *f, char *sec[3])
  21. "\n\t.quad %"PRId64
  22. "\n\t.quad 0\n\n",
  23. (int64_t)b->n);
  24. - else if (lg == 3)
  25. + else if (lg == 3) {
  26. + u.i64 = b->n;
  27. fprintf(f,
  28. "\n\t.quad %"PRId64
  29. " /* %f */\n\n",
  30. - (int64_t)b->n,
  31. - *(double *)&b->n);
  32. - else if (lg == 2) {
  33. - u.i = b->n;
  34. + u.i64, u.f64);
  35. + } else if (lg == 2) {
  36. + u.i32 = b->n;
  37. fprintf(f,
  38. "\n\t.int %"PRId32
  39. " /* %f */\n\n",
  40. - u.i, (double)u.f);
  41. + u.i32, u.f32);
  42. }
  43. }
  44. }
  45. --
  46. 2.45.2