From 00b89b5fc8a9345f5a3822211fcbed4939aa4691 Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Fri, 4 Sep 2026 13:12:08 +0100 Subject: [PATCH] Fixed logical NOT with 64-bit values on i386 --- i386.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/i386.c b/i386.c index 6f86632..aeba403 100644 --- a/i386.c +++ b/i386.c @@ -10487,12 +10487,33 @@ static int current_token_is_64bit_integer_value_now (void) { static int current_expression_mentions_64bit_symbol_now (void) { + struct token *saved_tok; + int result; + /* * Keep this deliberately token based. The old source-text scan was too * broad and could send ordinary runtime expressions through expr_const64(), * which rejects valid code with "integer constant expression expected". + * + * Unary operators do not change the width of the operand that must be + * evaluated. In particular, !uint64_value still has to load and test the + * complete 64-bit operand before producing its int boolean result. */ - return current_token_is_64bit_integer_value_now (); + if (current_token_is_64bit_integer_value_now ()) { + return 1; + } + + if (tok.kind != TOK_PLUS && tok.kind != TOK_MINUS && tok.kind != TOK_TILDE && tok.kind != TOK_XMARK) { + return 0; + } + + saved_tok = clone_current_token_now (); + get_token (); + + result = current_token_is_64bit_integer_value_now (); + unget_token (saved_tok); + + return result; } -- 2.34.1