Issue 171874
Summary return (NULL) will give incorrect warnings with -Wimplicit-void-ptr-cast
Labels new issue
Assignees
Reporter Leont
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to