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

Invalid implementation of SmallVector copy constructor and assignment operator #5255

Closed
DorpsGek opened this issue Jul 25, 2012 · 3 comments
Closed
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

adf88 opened the ticket and wrote:

In the SmallVector class, copy-constructor and assignment operator are templated. However, it doesn't suppress the compiler from generating default copy constructor/assignment implicitly. And that's what's happening on GCC e.g:

SmallVector<int, 1> foo;
SmallVector<int, 4> bar = foo; // calls templated constructor
SmallVector<int, 1> foo2 = foo; // calls implicitly generated copy constructor

(tested on Linux GCC 4.6.3, --enable-debug=3)

Fix-patch attached.

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5255
@DorpsGek
Copy link
Member Author

adf88 wrote:

fix-patch

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5255#comment11411

@DorpsGek
Copy link
Member Author

Alberth wrote:

And what code using the generated code is broken now?

In addition, assignment operators are different from copy constructors; you cannot blindly overwrite existing data in the former.
Also, you have to check for self-assignment, although the current implementation doesn't do that either.

I suspect the SmallVector class is not designed to be used in the way you describe.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5255#comment11412

@DorpsGek
Copy link
Member Author

frosch closed the ticket.

Reason for closing: Fixed

in r24448. Thanks for the diff!


This comment was imported from FlySpray: https://bugs.openttd.org/task/5255

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant