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
Broken conversion char* -> std::string #2132
Comments
Phew, nice one. While integrating the test case, I also noticed that this generates invalid code: cdef string& func(string& s):
return s It creates a return value variable of type Do you see a way how to make this work? The memory management also looks fishy here. Is your example actually safe in C++? We can't just wrap the literal in |
Cython's support for C++ references in general is very poor. So I wouldn't worry in particular about this specific example. |
Well, be fair - it's not that bad and it is getting better over time. I found this explanation for what I suspected, which suggests that your code is incorrect. In C++, you cannot pass a string literal into a function that takes a non-const Now, that does not mean that Cython could not implement this, and you already showed that the previously generated code worked - despite being somewhat suboptimal. It even generated a warning in fact, although not visible by default: "Cannot pass Python object as C++ data structure reference (string &), will pass by copy.". I've restored the old behaviour and improved it a bit, let's see who else complains now. |
OK, I did not think about the difference between |
With migration from Cython 0.27 to 0.28.2 I noticed a compilation error "Cannot assign type 'vector[int64]' to 'const vector[int64]'" in a codebase that
I traced the change to removal of lines 5545, 5546: 9a88d3c#diff-4548b0f91e1236cc95eb7cbd6a960533L5545. @scoder , is the new behavior an intended one? |
Opened #2211 for my last comment. |
Cython-0.28b1 miscompiles
The call
foo("hello")
becomesIn Cython-0.27.3, this was instead compiled to
The text was updated successfully, but these errors were encountered: