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

[BUG] vector[bint] causes odd behaviour in vector[int] #5516

Closed
tsierens opened this issue Jul 8, 2023 · 0 comments · Fixed by #5518
Closed

[BUG] vector[bint] causes odd behaviour in vector[int] #5516

tsierens opened this issue Jul 8, 2023 · 0 comments · Fixed by #5518

Comments

@tsierens
Copy link

tsierens commented Jul 8, 2023

Describe the bug

I found some undesired behaviour while using the C++ vector class. A specific inclusion of a bint variable causes other ints to become bints.

This code

%%cython -a --cplus
from libcpp.vector cimport vector
print(<vector[int]>range(10))

outputs
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
which is expected.

But this code

%%cython -a --cplus
from libcpp.vector cimport vector
cdef vector[bint] foobar = []
print(<vector[int]>range(10))

outputs
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
which is very unexpected

I think something is wrong here.

Code to reproduce the behaviour:

from libcpp.vector cimport vector
cdef vector[bint] foobar = []
print(<vector[int]>range(10))

Expected behaviour

<vector[int]>range(10) should be a vector with elements [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], but it produces a vector of bint instead.

OS

Windows

Python version

3.11

Cython version

0.29

Additional context

No response

da-woods added a commit to da-woods/cython that referenced this issue Jul 9, 2023
The previously clashed with "int" containers.

Fixes cython#5516
scoder pushed a commit that referenced this issue Jul 9, 2023
The previously clashed with "int" containers.

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

Successfully merging a pull request may close this issue.

2 participants