[Github-comments] [geany/geany] Fix clang warnings: Use empty array instead of NULL pointer (#2889)

Colomban Wendling notifications at xxxxx
Sun Sep 5 21:04:10 UTC 2021


@b4n requested changes on this pull request.

The C standard forbids zero-size arrays.  Yes, [GCC](https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html) and Clang do allow them as an extension (yet it's not *truly* 0-sized, but basically a VLA), GCC even discourages usage in your use case:
> Declaring zero-length arrays [anywhere but as the last member of a structure], including as interior members of structure objects or as non-member objects, is discouraged

At any rate, it's not valid ISO C, so any compiler would be right to forbid it.  And both GCC and Clang are unhappy about them when passed `-pedantic` (GCC: *error: zero or negative size array ‘foo’*, CLang: *warning: zero size arrays are an extension [-Wzero-length-array]*).

---
It's sad Clang doesn't see that the `NULL` check makes its warning moot, but the fix you propose is not OK as it's not valid C -- and thus likely rejected (rightly) by some compilers (I would guess MSVC might not like it, and maybe some other less common ones).



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/2889#pullrequestreview-746683433
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20210905/df9fc7fd/attachment.htm>


More information about the Github-comments mailing list