Skip to content
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

change assert by FC_ASSERT #1762

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/protocol/include/graphene/protocol/ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ struct graphene_extension_from_variant_visitor
if( it != vo.end() )
{
from_variant( it->value(), (value.*member), _max_depth );
assert( count_left > 0 ); // x.find(k) returns true for n distinct values of k only if x.size() >= n
FC_ASSERT( count_left > 0 ); // x.find(k) returns true for n distinct values of k only if x.size() >= n
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a meaningful error message.
Actually I can't think of a situation where this assertion would trigger.
The visitor is called once per extension member, with distinct names. Only names that are found are counted, so the only way to have count_left == 0 is to call it more than once with a given name.

The only case I can think of where this could happen is if the extension type is a derived class, and both the parent and the extension have a member with the same name. Or if a member name appears more than once in the corresponding FC_REFLECT macro. Both would be a bug in core, not a problem with the incoming variant.

--count_left;
}
}
Expand Down