[clang] [OpenCL] Diagnose error for zero-length array (PR #193163)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 21 08:03:14 PDT 2026


AaronBallman wrote:

> This change needs a release note. Please add an entry to `clang/docs/ReleaseNotes.rst` in the section the most adapted to the change, and referencing any Github issue this change fixes. Thanks!
> 
> This should be highlighted in the potentially breaking change section. And maybe it's something we should keep supporting with a warning, as it was never rejected before by clang

+1 to these suggestions; this has been a rather common idiom in C for ages (flexible array members eventually replaced this idiom) so I am worried about breaking code.

Searching for the idiom in C shows a lot of hits:
https://sourcegraph.com/search?q=context:global+lang:C+%5E%5Cs*%5BA-Za-z0-9_%5D%2B%5Cs%2B%5BA-Za-z0-9_%5D%2B%5C%5B0%5C%5D%3B%24&patternType=regexp&sm=0

But searching for the same in OpenCL shows none:
https://sourcegraph.com/search?q=context:global+lang:OpenCL+%5E%5Cs*%5BA-Za-z0-9_%5D%2B%5Cs%2B%5BA-Za-z0-9_%5D%2B%5C%5B0%5C%5D%3B%24&patternType=regexp&sm=0
but I can't tell whether that's because it's not searching .h files and only .cl ones.

@svenvh do you know if other OpenCL compilers also support this extension or is this unique to Clang? (Trying to gauge how disruptive this change is likely to be in practice.)

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


More information about the cfe-commits mailing list