-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
Description
#include <stdio.h>
int main()
{
unsigned int ints[2] = {0xaabbccdd, 0xff};
unsigned char* bytes = (unsigned char*)ints;
printf("0x%x\n", bytes[1] | 1);
}Calling
scan-build clang false-positive.cGives
scan-build: Using '/usr/lib/llvm-22/bin/clang' for static analysis
false-positive.c:7:31: warning: The left operand of '|' is a garbage value [core.UndefinedBinaryOperatorResult]
7 | printf("0x%x\n", bytes[1] | 1);
| ~~~~~~~~ ^
1 warning generated.
scan-build: Analysis run complete.
scan-build: 1 bug found.
scan-build: Run 'scan-view /tmp/scan-build-2025-11-18-191927-81-1' to examine bug reports.
Checked for versions:
Debian clang version 22.0.0 (++20251015112211+4ad625b15bc1-1~exp1~20251015112229.1767)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-22/bin
And
Debian clang version 19.1.7 (++20250114103228+cd708029e0b2-1~exp1~20250114103334.78)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-19/bin