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

Incorrect order of arguments #36

Open
drmeister opened this issue Jul 20, 2021 · 1 comment
Open

Incorrect order of arguments #36

drmeister opened this issue Jul 20, 2021 · 1 comment

Comments

@drmeister
Copy link

drmeister commented Jul 20, 2021

I'm pretty sure there is a bug in the order of arguments passed here:

https://github.com/luabind/luabind/blob/master/src/inheritance.cpp#L193

I think it should be:

m_cache.put(src, target, dynamic_id, object_offset, -1, cache::invalid);

The cache::invalid value only makes sense as a std::ptrdiff_t and the compiler accepts the wrong order because of implicit type casting of integer types.

I've copied a lot of luabind code for my own binding library 'clbind' in clasp (https://github.com/clasp-developers/clasp.git) - a Common Lisp that interoperates with C++.

@keinstein
Copy link

As far as I know the signature is

 void cache::put(
      class_id src, class_id target, class_id dynamic_id
    , std::ptrdiff_t object_offset, std::ptrdiff_t offset, int distance)

with

     static std::ptrdiff_t const unknown;
      static std::ptrdiff_t const invalid;

So your suggestion casts -1 to std::ptrdiff_t and cache::invalid from std::ptrdiff_t to int.

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

No branches or pull requests

2 participants