-
Notifications
You must be signed in to change notification settings - Fork 7.9k
zend: introducing ZEND_ELEMENT_COUNT for struct's dynamic arrays. #12650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It is mostly for ubsan and helping array bound checking.
This is a really nice feature that I've seen used in Linux too to prevent bugs. I'm not sure if element_count is actually already implemented (seems like the feature request is open atm), but counted_by is available in Clang. |
yes for gcc it s still in review. |
Does this work on structs with the struct hack? (i.e. |
I ve tried with zend_type_list locally, seems to work. I ve tried the limit of it, changing to pointers or non integral counters and it fails to compile rightfully for those. |
Great, thank you! My regex was sub-optimal for obvious reasons (* requirement). I used another one (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine.
…not stored in the same layout (not needed)
d31fffe
to
9a43fee
Compare
It would be good to eventually get rid of the struct hack as well to also make builtin size checks work. Remember reading this article about work that is being done in Linux kernel for that: https://lwn.net/Articles/908817/ |
As far as I understand it, using flexible array members is no-go because we support C++ compilers to interpret our headers. C++ still doesn't support flexible array members. So until we have a strategy for that, I don't think we can get rid of the struct hack. |
It is mostly for ubsan and helping array bound checking.