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

clang compatibility fixes #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/gadgetlib1/protoboard.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var_index_t protoboard<FieldT>::allocate_var_index(const std::string &annotation
assert(annotation != "");
constraint_system.variable_annotations[next_free_var] = annotation;
#else
UNUSED(annotation);
libff::UNUSED(annotation);
#endif
++constraint_system.auxiliary_input_size;
values.emplace_back(FieldT::zero());
Expand Down Expand Up @@ -103,7 +103,7 @@ void protoboard<FieldT>::add_r1cs_constraint(const r1cs_constraint<FieldT> &cons
assert(annotation != "");
constraint_system.constraint_annotations[constraint_system.constraints.size()] = annotation;
#else
UNUSED(annotation);
libff::UNUSED(annotation);
#endif
constraint_system.constraints.emplace_back(constr);
}
Expand Down
4 changes: 2 additions & 2 deletions src/knowledge_commitment/knowledge_commitment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ struct knowledge_commitment {
template<typename T1, typename T2, mp_size_t m>
knowledge_commitment<T1,T2> operator*(const libff::bigint<m> &lhs, const knowledge_commitment<T1,T2> &rhs);

template<typename T1, typename T2, mp_size_t m, const libff::bigint<m> &modulus_p>
knowledge_commitment<T1,T2> operator*(const libff::Fp_model<m, modulus_p> &lhs, const knowledge_commitment<T1,T2> &rhs);
template<typename T1, typename T2, typename T>
Copy link
Member

@tromer tromer Mar 27, 2017

Choose a reason for hiding this comment

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

This less-specific templatization loses information, and could cause future problems overloading operator* for other types. The change assumes that anything you'd multiply by a knowledge_commitment would have an as_bigint() method.
Does the original exceed C++11, or is clang (and which version?) showing incomplete C+1+11 support here?

Copy link
Contributor Author

@kobigurk kobigurk Mar 27, 2017

Choose a reason for hiding this comment

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

Agree, this causes me to feel uneasiness as well, maybe we can figure out a compromise.
As far as it seems to me, it's a different interpretation regarding non-type template parameter deduction - gcc decides to infer "bigint" from "const bigint &" while clang is being more strict and decides not to.

This is a contained example that shows the same behavior:
http://coliru.stacked-crooked.com/a/583904c911c2e84b

knowledge_commitment<T1,T2> operator*(const T &lhs, const knowledge_commitment<T1,T2> &rhs);

template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out, const knowledge_commitment<T1,T2> &kc);
Expand Down
4 changes: 2 additions & 2 deletions src/knowledge_commitment/knowledge_commitment.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ knowledge_commitment<T1,T2> operator*(const libff::bigint<m> &lhs, const knowled
lhs * rhs.h);
}

template<typename T1, typename T2, mp_size_t m, const libff::bigint<m> &modulus_p>
knowledge_commitment<T1,T2> operator*(const libff::Fp_model<m, modulus_p> &lhs, const knowledge_commitment<T1,T2> &rhs)
template<typename T1, typename T2, typename T>
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

knowledge_commitment<T1,T2> operator*(const T &lhs, const knowledge_commitment<T1,T2> &rhs)
{
return (lhs.as_bigint()) * rhs;
}
Expand Down