-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-negativeWarning doesn't fire when it shouldWarning doesn't fire when it should
Description
Greetings,
while compiling the following program with -Wnull-dereference no warning is produced by clang (Ubuntu clang version 20.0.0 (++20241009053718+c198f775cdcd-1~exp1~20241009053853.1977):
#include <stdio.h>
int main(int argc, char **argv)
{
int *yikes = NULL;
*yikes = 1;
fprintf(stdout, "Hello world!\n");
return *yikes;
}Expected result would be like what you get with gcc (although it only seems to work with gcc if you have optimizations enabled and not with -O0):
$ gcc -O1 -Wnull-dereference -o yikes yikes.c
yikes.c: In function ‘main’:
yikes.c:8:12: warning: null pointer dereference [-Wnull-dereference]
8 | *yikes = 1;
| ~~~~~~~^~~
yikes.c:12:12: warning: null pointer dereference [-Wnull-dereference]
12 | return *yikes;
| ^~~~~~
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-negativeWarning doesn't fire when it shouldWarning doesn't fire when it should