Fixed logical NOT with 64-bit values on i386
authorRobert Pengelly <robertapengelly@hotmail.com>
Fri, 4 Sep 2026 12:12:08 +0000 (13:12 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Fri, 4 Sep 2026 12:12:08 +0000 (13:12 +0100)
i386.c

diff --git a/i386.c b/i386.c
index 6f866323bdd42a471e211722157f9227eb5e8d0d..aeba403fd3be14feb04492dcb1c745223789b45d 100644 (file)
--- 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;
 
 }