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

size_t -> long, possible loss of data warnings calling object_method_typed() #142

Open
diablodale opened this issue Apr 7, 2020 · 0 comments
Labels

Comments

@diablodale
Copy link

Four occurrences of 'argument': conversion from 'size_t' to 'long', possible loss of data
due to using .size() which returns a size_t as a value to an argument that accepts long

return max::object_method_typed(m.ob, method_name, as.size(), &as[0], nullptr);
}
else if (m.type == max::A_GIMMEBACK) {
atoms as { arg1 };
max::t_atom rv {};
max::object_method_typed(m.ob, method_name, as.size(), &as[0], &rv);
return rv;
}
else {
if (typeid(T1) != typeid(atom))
return m.fn(m.ob, arg1);
else {
// atoms must be converted to native types and then reinterpreted as void*
// doubles cannot be converted -- supporting those will need to be handled separately
return m.fn(m.ob, atom_to_generic(arg1));
}
}
}
template<typename T1, typename T2>
atom operator()(symbol method_name, T1 arg1, T2 arg2) {
auto m { find_method(method_name) };
if (m.type == max::A_GIMME) {
atoms as { arg1, arg2 };
return max::object_method_typed(m.ob, method_name, as.size(), &as[0], nullptr);
}
else if (m.type == max::A_GIMMEBACK) {
atoms as { arg1, arg2 };
max::t_atom rv {};
max::object_method_typed(m.ob, method_name, as.size(), &as[0], &rv);

Quick fix is to cast the size_t to a long and hope that arg is never more than 2GB.
Cleaner is that cast but also to do a compile-time size check since you will know T1 and T2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants