-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix CodeGen V2 for zero-length array #453
Fix CodeGen V2 for zero-length array #453
Conversation
The recursive template implemented for `validate_size` does not support incomplete types, like zero-length array. By splitting the `validate_size` struct in two parts: 1. `validate_size_eq` that does the actual size check, and 2. `validate_size` that preserves the previous interface and inherit from `validate_size_eq`, we get the same interface and feature than previously, but without the recursive template that doesn't support incomplete types.
62a3778
to
cff773b
Compare
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.
Not sure how much we care about breaking codegen-v1 at this point, but this does seem to. Pretty easy to make it work with both :) if we have consensus that codegen-v1 is dead that I missed then you don't need to worry.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #453 +/- ##
==========================================
+ Coverage 62.38% 62.41% +0.02%
==========================================
Files 123 123
Lines 12007 12006 -1
Branches 1956 1955 -1
==========================================
+ Hits 7491 7493 +2
+ Misses 3571 3570 -1
+ Partials 945 943 -2 ☔ View full report in Codecov by Sentry. |
cff773b
to
ec40543
Compare
TreeBuilder did not consider a zero-length array like a container and never read the array's sizeof stored in the data buffer, leading to a mismatch between bytes written vs read out of the buffer. Now, `TreeBuilder::isContainer` does consider zero-length array like a container and properly consume all the object sizes in the buffer.
ec40543
to
6a26f9a
Compare
Summary
Fix issue #295
validate_size
template with a non-recursive one, making CodeGen compileIs it ok to process zero-length array as container?
I had to modify the test's results to all
0
sizes. Is this the behavior expected? Or should it report an exclusive size of1
for theFoo
struct?Test plan
The example provided in #295 now passes successfully and has been enabled in the integration tests.