-Warray-bounds seems over-zealous on Clang

So, my second blog post on this subject has a benchmark that sees
clang do quite well:

It was picked up by Reddit, and has received a few thousand unique
visitors since yesterday.

Anyway, I'm disappointing that no headway has been made on this issue
after a week. Chandler, could you please let me know if it is still
your intent to fix this problem, and if so whether or not you favour
suppressing it in C99 too?

Sorry about the delays here. My time kept geting co-opted by burning fires on other fronts.

Chris ended up doing a quick patch for this a couple of days ago, and I’ve now gone through and applied most of the logic discussed here as of r136965.

Specifically, the array-bounds warning is now suppressed iff:

  1. The array size is one, and
  2. The array is declared as the last field in a struct, and
  3. The array’s size is written as a literal ‘1’ rather than being expanded from a macro or substituted from a template argument

I’ve not added a warning in C99 or C++ modes which suggests flexible arrays as its not clear to me how productive such a warning would be. Given the restrictions above, it is very unlikely to represent a bug (i hope!) and so warning seems more noise than signal.

Let me know if you hit issues with this logic.

This is the exact behaviour I was looking for, because, as you know, I
think the chances of the "consider flexible arrays" warning being
useful was very close to zero, and there is really no reason to not
give the warning under circumstances that are not exactly consistent
with the use of the idiom.

Thank you Chandler, and thank you Nicola.