From ad6c59e3ea003aab543b39a41d6acc60aaf67913 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 17 Oct 2026 04:13:10 +0200 Subject: Work around miscompilation bug with clang(1) 22.1.8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original code works with '-Weverything' but crashes with '-Weverything -Og -g' Assembly difference: @@ -1752,7 +1752,7 @@ .Ltmp210: #DEBUG_VALUE: parse_line:i <- 1 .loc 0 58 23 is_stmt 1 # Blocks.parse.c:58:23 @[ ./parse-common.c:87:2 ] - movsbq -1, %rdx + movsbq -1(%rbp), %rdx .Ltmp211: .loc 0 58 2 is_stmt 0 # Blocks.parse.c:58:2 @[ ./parse-common.c:87:2 ] testb $32, 1(%rax,%rdx,2) @@ -1772,7 +1772,7 @@ #DEBUG_VALUE: parse_line:low <- $r13 #DEBUG_VALUE: parse_line:high <- $rsi #DEBUG_VALUE: parse_line:i <- undef - .loc 0 59 12 is_stmt 1 # Blocks.parse.c:59:12 @[ ./parse-common.c:87:2 ] + .loc 0 59 15 is_stmt 1 # Blocks.parse.c:59:15 @[ ./parse-common.c:87:2 ] movb $0, (%rcx) .loc 0 58 15 # Blocks.parse.c:58:15 @[ ./parse-common.c:87:2 ] movq (%r12), %rax Signed-off-by: Mattias Andrée --- Blocks.parse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Blocks.parse.c b/Blocks.parse.c index d167b66..1ae9fa9 100644 --- a/Blocks.parse.c +++ b/Blocks.parse.c @@ -55,8 +55,8 @@ parse_line(char *text, size_t lineno) name = text; while (*text && *text != ';') text++; - for (i = 1u; isspace(text[-i]); i++) - text[-i] = '\0'; + for (i = 1u; isspace(*(text - i)); i++) + *(text - i) = '\0'; if (*text == ';') { static int warned = 0; -- cgit v1.3.1