On Mon, 19 Jan 2026, Alejandro Colomar wrote: > > Furthermore, _Countof for array parameters *does* introduce new issues > > because compatibility above can only refer to the types *after* > > adjustment, but with _Countof the question of matching lengths *before* > > adjustment comes into play > > IMO, GCC already requires type compatibility on array parameters taking > into account their length, as an extension. This is implemented as part > of -Warray-parameter=.
A warning (even if given at all in the forward declaration case) doesn't exactly say what the semantics are for _Countof on array parameters when the lengths differ. It says the code is questionable - and indeed it is. But code that produces a warning (with no error) still has semantics, so it needs to be clear what the semantics are for _Countof on array parameters in this case. (And I'd be dubious of defining cases where the lengths are different expressions as constraint violations simply because of the possibility that they differ at runtime, since it's hard to define a precise rule for when two expressions should be considered "the same".) -- Joseph S. Myers [email protected]
