Bug 13990 – std.algorithm.move incorrectly uses hasAliasing for class references

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-16T19:51:00Z
Last change time
2015-02-18T03:41:20Z
Assigned to
schveiguy
Creator
schveiguy

Comments

Comment #0 by schveiguy — 2015-01-16T19:51:49Z
If we have an opaque class, we can't move the reference with std.algorithm.move: import std.algorithm.move class S; void main() { S s; S s2; std.algorithm.move(s, s2); // Error, size of S unknown. } However, all move has to do is assignment in this case. The issue is that we have a static if that checks hasAliasing on the class type to do a check for internal pointers, but that is only relevant for structs. It should be moved inside the check to see if it's a struct. Doing pull request now.
Comment #1 by schveiguy — 2015-01-16T20:14:43Z
PR: https://github.com/D-Programming-Language/phobos/pull/2876 Note, I couldn't just put the code inside structs, because unit tests also want to make sure a pointer isn't self-pointing.
Comment #2 by github-bugzilla — 2015-01-20T20:19:11Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/0afa52f5996c0e80e3e0067fa14bfc9b955bebca Fix issue 13990, Now you can move opaque classes. https://github.com/D-Programming-Language/phobos/commit/02be4bdd5593794eb40848e5c2e3304e52fa83e6 Merge pull request #2876 from schveiguy/issue13990 Fix issue 13990 -- std.algorithm.move incorrectly uses hasAliasing for class references
Comment #3 by zeljko.grk — 2015-01-21T08:41:47Z
fixed: void move(T)(ref T source, ref T target) not fixed: T move(T)(ref T source)
Comment #4 by schveiguy — 2015-01-22T13:06:05Z
Bleh, I can't be expected to find all the instances of a function I never use ;) I'll add another PR.
Comment #5 by schveiguy — 2015-01-22T15:26:24Z
Comment #6 by github-bugzilla — 2015-01-22T16:04:14Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/8ccd882556b13afa9b8f72c0c41e72709e701c41 Fix second move overload for issue 13990 https://github.com/D-Programming-Language/phobos/commit/8814b27d8d333f07dfd00dda2a6c4a7dc35cc348 Merge pull request #2894 from schveiguy/issue13990_b Fix issue 13990 part 2 -- std.algorithm.move incorrectly uses hasAliasing for class references
Comment #7 by github-bugzilla — 2015-02-18T03:41:20Z