[clang] [clang-tools-extra] [compiler-rt] [lldb] [Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (PR #157364)
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 17 16:29:58 PDT 2025
alexfh wrote:
> > This diagnostic fires in the following code - https://gcc.godbolt.org/z/G6sYcTnWc:
> > ...
> > Is this expected?
>
> Yes. The prototype of `f` is using a `locally` defined struct (see the `Wvisibility` diagnostic). So that type is ONLY visible on line 1.
Thanks for the explanation! Interestingly, neither of the two diagnostics is issued when compiling the code as C++, though I would expect this to be invalid C++ code. Any thoughts on how this works in C++?
...
> IF this is your code, I'd suggest doing a forward-declaration of `struct stat` outside of a function prototype.
Yep, a forward declaration (or better `#include <sys/stat.h>`) before the first use of `struct stat` is needed to make this code unambiguously correct.
https://github.com/llvm/llvm-project/pull/157364
More information about the cfe-commits
mailing list