[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays for stricter handling of flexible arrays

Martin Sebor via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 9 15:50:23 PDT 2022


msebor added a comment.

Quite a bit more code treats one-element trailing arrays as flexible array members than larger arrays, and may not be able to change (GCC is one example).  I wonder if it would be worthwhile to make it possible for code to specify that mode (e.g., by adding two options, or by having the new option accept an argument specifying the cutoff at which a trailing array is not considered a flexible array member).



================
Comment at: clang/docs/ReleaseNotes.rst:71-75
+- Clang now supports the ``-fstrict-flex-arrays`` to only consider trailing
+  arrays with unknown size arrays as flexible arrays. This breaks compatibility
+  with some legacy code but allows for better folding of
+  ``__builtin_object_size``.
+
----------------
This sentence looks mangled.  It should probably read something like
> Clang now supports the `-fstrict-flex-arrays` option to avoid treating trailing array members with a specified bound as flexible array members. The option yields more accurate `__builtin_object_size` results in most cases but may be overly conservative for some legacy code.

(The technical term is //flexible array member//.)

If the option also affects `__builtin_dynamic_object_size` it might be worth mentioning that as well, if only to highlight the latter built-in since it's more powerful.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126864/new/

https://reviews.llvm.org/D126864



More information about the cfe-commits mailing list