]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama : suppress unary minus operator warning (#8448)
authorDaniel Bevenius <redacted>
Fri, 12 Jul 2024 09:05:21 +0000 (11:05 +0200)
committerGitHub <redacted>
Fri, 12 Jul 2024 09:05:21 +0000 (12:05 +0300)
This commit updates the _try_copy lambda and moves the unary minus
operator to after the cast to int32_t.

The motivation for this that currently the following warning is
generated on windows:

```console
llama.cpp\src\llama.cpp(21147,30): warning C4146: unary minus operator
applied to unsigned type, result still unsigned
```

src/llama.cpp

index f91ac777969d98dacecc239c643bff4815f130f1..59b76a6d80cdf801740e4056bb6882f746bbbfb2 100644 (file)
@@ -21144,7 +21144,7 @@ int32_t llama_token_to_piece(const struct llama_model * model, llama_token token
             size--;
         }
         if (length < (int32_t)size) {
-            return (int32_t) -size;
+            return -(int32_t) size;
         }
         memcpy(buf, token, size);
         return (int32_t) size;