-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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 analyzer
Description
This program:
#include <stdlib.h>
struct foo {
char baz;
};
struct foo* bar() {
return(NULL);
}
int main() {
bar();
}
Will give the following warning when compiled with -Wimplicit-void-ptr-cast / -Wc++-compat
test.c:8:8: warning: implicit conversion when returning 'void *' from a function with result type 'struct foo *' is not
permitted in C++ [-Wimplicit-void-ptr-cast]
8 | return(NULL);
| ^~~~~~
1 warning generated.
Even though it's perfectly valid C++ (because NULL isn't a void pointer C++, so the expression (NULL) won't be a void pointer either) that clang++ doesn't have any issue with.
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 analyzer