From 96d75e78358d6c2643bfb7cc65744b8a6178c9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= Date: Sat, 1 Apr 2023 14:25:12 +0200 Subject: [PATCH] Remove aliasing violation in Fstring_lessp * src/fns.c (Fstring_lessp) : Remove strict aliasing violation. --- src/fns.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/fns.c b/src/fns.c index ff364c6..e3e11e2 100644 --- a/src/fns.c +++ b/src/fns.c @@ -499,10 +499,16 @@ DEFUN ("string-lessp", Fstring_lessp, Sstring_lessp, 2, 2, 0, /* First compare entire machine words. */ typedef size_t word_t; int ws = sizeof (word_t); - const word_t *w1 = (const word_t *) SDATA (string1); - const word_t *w2 = (const word_t *) SDATA (string2); - while (b < nb - ws + 1 && w1[b / ws] == w2[b / ws]) - b += ws; + while (b < nb - ws + 1) + { + word_t w1; + word_t w2; + memcpy (&w1, SDATA (string1) + b, sizeof (w1)); + memcpy (&w2, SDATA (string2) + b, sizeof (w2)); + if (w1 != w2) + break; + b += ws; + } } /* Scan forward to the differing byte. */ -- 2.40.0