[PATCH] D108230: [analyzer] Ignore single element arrays in getStaticSize() conditionally
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 21 22:22:57 PST 2022
steakhal added a comment.
In D108230#3942374 <https://reviews.llvm.org/D108230#3942374>, @xazax.hun wrote:
> I am a bit conflicted. It is unfortunate that C and C++ compilers regarded single element array members as flexible array members. On the other hand, looking at GCC, it recently added -fstrict-flex-arrays=2 <https://developers.redhat.com/articles/2022/09/29/benefits-limitations-flexible-array-members#nonconforming_compiler_extensions> as an option to no longer consider single element member arrays as FAM. So, it looks like the community wants to migrate away from this. My main concern is whether this option would make the experience worse for people who keep their code tidy and favor people who did not update their FAMs. Overall, I wonder if diagnosing single element arrays that are likely FAMs and suggesting users to fix their code is a better way forward.
This perfectly relates to my second point about raising that we should probably respect hence override our default behavior about FAMs. To clarify, I found it useful for allowing single elem FAMs if no compiler flag indicates otherwise.
This way CSA would be more in line with the compiler in terms of optimizations as well, which will only assume a sigle element array for such declaration if fstrict-flex-arrays=2 is present.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108230/new/
https://reviews.llvm.org/D108230
More information about the cfe-commits
mailing list