Add implicit IGNORE_IF_UNPOPULATED for MessageOneofRule fields#110
Merged
srikrsna-buf merged 5 commits intosk/oneoffrom Jun 13, 2025
Merged
Add implicit IGNORE_IF_UNPOPULATED for MessageOneofRule fields#110srikrsna-buf merged 5 commits intosk/oneoffrom
IGNORE_IF_UNPOPULATED for MessageOneofRule fields#110srikrsna-buf merged 5 commits intosk/oneoffrom
Conversation
Signed-off-by: Sri Krishna <skrishna@buf.build>
timostamm
approved these changes
Jun 13, 2025
Signed-off-by: Sri Krishna <skrishna@buf.build>
Signed-off-by: Sri Krishna <skrishna@buf.build>
ghost
approved these changes
Jun 13, 2025
| } | ||
| fields.push_back(fdesc); | ||
| fields.push_back(fdesc); | ||
| allMsgOneofs.insert(name) ; |
There was a problem hiding this comment.
Suggested change
| allMsgOneofs.insert(name) ; | |
| allMsgOneofs.insert(name); |
Something odd happened to the formatting on this line.
| FieldRules fieldLvlOvr; | ||
| fieldLvlOvr.CopyFrom(fieldLvl.get()); | ||
| fieldLvlOvr.set_ignore(IGNORE_IF_UNPOPULATED); | ||
| fieldLvl = fieldLvlOvr; |
There was a problem hiding this comment.
This seems to me like it would rebind the std::reference_wrapper to a pointer to fieldLvlOvr whose lifetime ends after this scope. This may actually work but I think it is undefined behavior because the stack space is not guaranteed to be clobbered before it is read/copied. Maybe I am wrong?
I think the canonical way to do this safely is to allocate a new FieldRules in the current arena.
Signed-off-by: Sri Krishna <skrishna@buf.build>
Signed-off-by: Sri Krishna <skrishna@buf.build>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bufbuild/protovalidate#382