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 deduction of function object types #3200

Open
mje-nz opened this issue Oct 21, 2019 · 1 comment

Comments

@mje-nz
Copy link
Contributor

@mje-nz mje-nz commented Oct 21, 2019

cdef extern from "<functional>" namespace "std" nogil:
    cdef cppclass plus[T=*]:
        plus() except +
        T operator()(const T& lhs, const T& rhs) except +

def test(): 
    return plus[int]()(1, 2) 
test.cpp:1244:15: error: non-object type 'int (const int &, const int &)' is not assignable
    __pyx_t_1 = std::plus<int> ();
    ~~~~~~~~~ ^
1 error generated.

A temporary for std::plus<int> is generated as int __pyx_t_1(int const &, int const &), which fails to compile. Explicitly storing it in a temporary works:

def test(): 
    tmp = plus[int]()
    return tmp(1, 2) 
@scoder

This comment has been minimized.

Copy link
Contributor

@scoder scoder commented Oct 26, 2019

Seems a bug. PR welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.