Open Quuxplusone opened 4 years ago
Attached bounds.c
(2345 bytes, text/x-csrc): bounds checking PoC
If you want to forbid arrays of length 0 at compile-time, you can use -Wzero-length-array. Not sure it's worth adding an option to check at runtime; zero-length arrays are non-standard anyway.
Adding strict checks for arrays of length 1 makes sense, I think.
(The code that performs the check in question is isFlexibleArrayMemberExpr in clang/lib/CodeGen/CGExpr.cpp)
bounds.c
(2345 bytes, text/x-csrc)