-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
Clang seem to miss detecting the dangling pointer warning (Wdangling-pointer) found with GCC
Sample Program:
#include <stdio.h>
void test (int **p)
{
int x = 7;
*p = &x;
}
int main ()
{
int *xp = NULL;
test (&xp);
printf ("dereference of xp = %d\n", *xp);
return 0;
}
Compilation using clang:
No warnings reported
# clang -Wall -c dangling.c
#
Compilation using gcc:
# gcc -Wall -c dangling.c
dangling.c: In function test:
dangling.c:5:6: warning: storing the address of local variable x in *p [-Wdangling-pointer=]
5 | *p = &x;
| ~~~^~~~
dangling.c:4:7: note: x declared here
4 | int x = 7;
| ^
dangling.c:2:18: note: p declared here
2 | void test (int **p)
|
Compiler versions:
clang version 16.0.6
gcc (GCC) 13.2.1
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