H
Hacker News
Top
Best
New
Posted by chmaynard 12/3/2025
Checked-size array parameters in C
(lwn.net)
110 points
|
60 comments
page 2
halayli 12/4/2025
|
next
[-]
on a similar note, there are also these field attributes that are very helpful for catching similar issues:
https://clang.llvm.org/docs/AttributeReference.html#counted-...
1over137 12/4/2025
|
prev
[-]
Anyone know if there's a flag to tell clang to treat `void fn(int array[N])`
as if
it was `void fn(int array[static N])`?
int_19h 12/6/2025
|
parent
[-]
I don't think such a thing exists simply because it would break so many headers if you turned that on, it wouldn't be particularly useful.
1over137 12/6/2025
|
root
|
parent
[-]
Why would it break headers? Who writes fn(array[16]) expecting less that 16 elements?
int_19h 12/11/2025
|
root
|
parent
[-]
They might expect 16 elements if it's not null, but still consider null a valid value, for example.