January 29, 2014 [Issue 12024] [REG DMD2.065-b2] template instantiation for swap(SysTime, SysTime) fails | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | https://d.puremagic.com/issues/show_bug.cgi?id=12024 --- Comment #11 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-01-29 16:07:02 EET --- Derp, unit test line should be: struct S3{union{int m;const int c;}} -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 29, 2014 [Issue 12024] [REG DMD2.065-b2] template instantiation for swap(SysTime, SysTime) fails | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | https://d.puremagic.com/issues/show_bug.cgi?id=12024 --- Comment #12 from monarchdodra@gmail.com 2014-01-29 06:26:10 PST --- (In reply to comment #8) > It should be possibly by comparing .offsetof with other members. Smart. Unfortunatly, for a "recursive" implementation, it is a bit difficult to exploit: More often than not, you want to know before hand that you are about to process an aggregate in an union. (In reply to comment #9) > If a non-mutable field has one or more overlapped union _mutable_ fields, the whole struct is treated as modifiable. > > import std.traits : Unqual; > struct Rebindable(T) > { > union > { > T origin; > Unqual!T stripped; // overlapped union mutable field of 'origin' > } > } Yes, absolutely. That's what I had in mind. But as I said, even detecting that you are in an (anonymous) union is a bit difficult. Do-able with your suggestion, just... difficult. (In reply to comment #10) > Interesting. So this should "just work": > > diff --git a/std/algorithm.d b/std/algorithm.d > index 036b918..0ed5606 100644 > --- a/std/algorithm.d > +++ b/std/algorithm.d > @@ -2054,6 +2054,9 @@ void swap(T)(ref T lhs, ref T rhs) if > (is(typeof(lhs.proxySwap(rhs)))) > private template allMutableFields(T) > { > alias OT = OriginalType!T; > + static if (is(typeof({ T t = void; t = t; }))) > + enum allMutableFields = true; > + else > static if (is(OT == struct) || is(OT == union)) > enum allMutableFields = isMutable!OT && allSatisfy!(.allMutableFields, > FieldTypeTuple!OT); > else > @@ -2072,6 +2075,9 @@ unittest > struct S2{const int i;} > static assert( allMutableFields!S1); > static assert(!allMutableFields!S2); > + > + struct S3{union X{int m;const int c;}X x;} > + static assert( allMutableFields!S3); > } I think that's wrong, because "static if (is(typeof({ T t = void; t = t; })))" can work in the pressence of an opAssign: Complex structs with immutable members but with a valid opAssign can't be swapped. The only case where it would work is if T didn't have an opAssign to begin with. However, that test would be mostly useless, since we'd have to deploy code for structs that do have opAssign regardless. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 29, 2014 [Issue 12024] [REG DMD2.065-b2] template instantiation for swap(SysTime, SysTime) fails | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | https://d.puremagic.com/issues/show_bug.cgi?id=12024 --- Comment #13 from Kenji Hara <k.hara.pg@gmail.com> 2014-01-29 06:36:51 PST --- (In reply to comment #12) > (In reply to comment #8) > > It should be possibly by comparing .offsetof with other members. > > Smart. Unfortunatly, for a "recursive" implementation, it is a bit difficult to exploit: More often than not, you want to know before hand that you are about to process an aggregate in an union. > > (In reply to comment #9) > > If a non-mutable field has one or more overlapped union _mutable_ fields, the whole struct is treated as modifiable. > > > > import std.traits : Unqual; > > struct Rebindable(T) > > { > > union > > { > > T origin; > > Unqual!T stripped; // overlapped union mutable field of 'origin' > > } > > } > > Yes, absolutely. That's what I had in mind. But as I said, even detecting that you are in an (anonymous) union is a bit difficult. Do-able with your suggestion, just... difficult. I think adding std.traits.isBlitAssignable(T) for the purpose would be good. And you can refer the code in the compiler. https://github.com/D-Programming-Language/dmd/blob/master/src/mtype.c#L8588 int TypeStruct::isAssignable() -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 30, 2014 [Issue 12024] [REG DMD2.065-b2] template instantiation for swap(SysTime, SysTime) fails | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | https://d.puremagic.com/issues/show_bug.cgi?id=12024 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull, rejects-valid --- Comment #14 from Kenji Hara <k.hara.pg@gmail.com> 2014-01-30 01:55:30 PST --- https://github.com/D-Programming-Language/phobos/pull/1891 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 31, 2014 [Issue 12024] [REG DMD2.065-b2] template instantiation for swap(SysTime, SysTime) fails | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | https://d.puremagic.com/issues/show_bug.cgi?id=12024 --- Comment #15 from github-bugzilla@puremagic.com 2014-01-31 03:28:55 PST --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/2d32c78af43a3d0a1b9015a8c971cefed9a1035f fix Issue 12024 - template instantiation for swap(SysTime, SysTime) fails https://github.com/D-Programming-Language/phobos/commit/b8f242e78f587f41aa344173b8961bf613e20c0d Merge pull request #1891 from 9rnsr/fix12024 [REG2.065a] Issue 12024 - template instantiation for swap(SysTime, SysTime) fails -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 31, 2014 [Issue 12024] [REG DMD2.065-b2] template instantiation for swap(SysTime, SysTime) fails | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | https://d.puremagic.com/issues/show_bug.cgi?id=12024 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 01, 2014 [Issue 12024] [REG DMD2.065-b2] template instantiation for swap(SysTime, SysTime) fails | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | https://d.puremagic.com/issues/show_bug.cgi?id=12024 --- Comment #16 from github-bugzilla@puremagic.com 2014-02-01 04:51:01 PST --- Commit pushed to 2.065 at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/84422029eb26ccea2cd97422c2e731792ae1e114 Merge pull request #1891 from 9rnsr/fix12024 [REG2.065a] Issue 12024 - template instantiation for swap(SysTime, SysTime) fails Conflicts: std/algorithm.d -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 28, 2014 [Issue 12024] [REG DMD2.065-b2] template instantiation for swap(SysTime, SysTime) fails | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | https://d.puremagic.com/issues/show_bug.cgi?id=12024 --- Comment #17 from github-bugzilla@puremagic.com 2014-02-27 20:13:09 PST --- Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/84422029eb26ccea2cd97422c2e731792ae1e114 Merge pull request #1891 from 9rnsr/fix12024 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation