* Jonathan Wakely:

>> The attribute provide "in-langauge" support for the same functionality
>> in a way that is consistent with [[fallthru]], and similar.
>
> C already allows in-language support for it, for 26 years now. If
> somebody chooses to use -Wvla in non-C89 code, doesn't that mean they
> actually want these warnings? The answer seems to be "don't do that
> then". Adding an very narrowly focused attribute to say "don't warn
> about this one very specific thing that we don't warn about anyway,
> because it's valid C" seems like a very bad idea. Somebody has to
> develop and test and maintain that attribute forever, for a very
> narrow use case which is arguably just user error. Don't use -Wvla if
> you want to compile code that uses VLAs.
>
> Your original motivation says:
>
>> However, there are occasional VLAs that are intentionally
>> bounded/validated (e.g., small scratch buffers sized from known limits).
>
> If it has a known limit, why not just use a constant as the bound, so
> it's not a VLA at all?
>
> And if it's only an occasional use, why is the existing pragma
> solution so unusable? It already works, with all modern versions of
> GCC.
>
> That said, maybe adorning the declaration with __extension__ could
> disable the warning. That would avoid needing a new attribute just for
> this one warning.

Furthermore, if VLAs are purely used for documentation purposes and
checking by static analyzers (and not actual allocations), it may be
possible to replace them with a counted_by attribute.  This requires
interface changes, though.

Thanks,
Florian

Reply via email to