[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (PR #157364)

Aaron Ballman via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 23 06:49:18 PDT 2025


AaronBallman 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! TIL about `function prototype scope` in C. 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++? (https://gcc.godbolt.org/z/bhjYKdG36)

C++ is surprisingly different from C with a lot of these basics. The issue here is that, in C you can introduce a type anywhere you can spell a type name, but the same is not true in C++: https://godbolt.org/z/bfseWxsWq So the issue here is that `struct stat` is introducing the type into a particular scope and that changes lookup behavior; C++ doesn't have the issue because you cannot introduce a new type in a function parameter list so their lookup behavior is different.




https://github.com/llvm/llvm-project/pull/157364


More information about the lldb-commits mailing list