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] Taking a pointer to a const memoryview loses the constness #5639

Closed
da-woods opened this issue Aug 22, 2023 · 0 comments · Fixed by #5987
Closed

[BUG] Taking a pointer to a const memoryview loses the constness #5639

da-woods opened this issue Aug 22, 2023 · 0 comments · Fixed by #5987

Comments

@da-woods
Copy link
Contributor

da-woods commented Aug 22, 2023

Describe the bug

It's possible to get a non-const pointer from a const memoryview with no warnings and no casts

Code to reproduce the behaviour:

def f(const double[::1] x):
    cdef double *xptr = &x[0]

Expected behaviour

Constness should be preserved.

I think we probably have to make this a warning rather than an error - there's almost certain code depending on it

OS

Linux

Python version

3.11.4

Cython version

3.0.0 ish

Additional context

scikit-learn/scikit-learn#27125

You do get a C warning (with GCC) but not a Cython warning

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