1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

tests: Fix undefined behaviour.

* tests/test2.c (main): Cast bytes to unsigned before shifting left.
This commit is contained in:
Bruno Haible
2022-02-08 01:16:48 +01:00
parent 6d53a2dbe0
commit d89cab8712
2 changed files with 6 additions and 1 deletions

View File

@@ -45,7 +45,7 @@ main (int argc, char *argv[])
char *p = buf;
while (fread (p, 2, 1, stdin) == 1)
{
if ((p[0] << 8) + p[1] == '\n')
if (((unsigned char) p[0] << 8) + (unsigned char) p[1] == '\n')
break;
p += 2;
}