digitalmars.D.bugs - [Issue 11722] New: Qualifier-only casts should not invoke opCast
- d-bugmail puremagic.com (38/38) Dec 10 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11722
- d-bugmail puremagic.com (10/10) Dec 10 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11722
- d-bugmail puremagic.com (11/11) Dec 11 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11722
- d-bugmail puremagic.com (11/11) Dec 11 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11722
- d-bugmail puremagic.com (10/10) Dec 11 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11722
- d-bugmail puremagic.com (6/6) Dec 11 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11722
- d-bugmail puremagic.com (17/27) Dec 12 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11722
- d-bugmail puremagic.com (17/43) Dec 12 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11722
- d-bugmail puremagic.com (7/37) Dec 12 2013 https://d.puremagic.com/issues/show_bug.cgi?id=11722
https://d.puremagic.com/issues/show_bug.cgi?id=11722 Summary: Qualifier-only casts should not invoke opCast Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: k.hara.pg gmail.com This is a spin-off issue from bug 5747. D has a cast syntax for modifying just only the type qualifier of the operand. http://dlang.org/expression#CastExpression CastExpression: cast ( Type ) UnaryExpression cast ( CastQual ) UnaryExpression <-- cast ( ) UnaryExpression <-- However, if the operand is class or struct, and has opCast member function, the qualifier-cast cast(qual)exp is translated to cast(qual(typeof(exp))exp, then it will unintendedly invoke opCast. For example, following code wrongly asserts in C.opCast. class C { T opCast(T)() { assert(0); } } void main() { C c = new C(); shared C sc = cast(shared)c; } I think this is not good behavior in generic code, and should be fixed. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 10 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11722 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull https://github.com/D-Programming-Language/dmd/pull/2946 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 10 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11722 Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/dab021c5b716b3a6eedbb1d883ce55f084b98aca fix Issue 11722 - Qualifier-only casts should not invoke opCast https://github.com/D-Programming-Language/dmd/commit/b32a5205390f69e3fc72b3acb912306f22616fbf Issue 11722 - Qualifier-only casts should not invoke opCast -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 11 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11722 Max Samukha <samukha voliacable.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |samukha voliacable.com PST --- I find the existing behavior reasonable enough, provided it is cast(qual(unqual(typeof(exp)))exp instead of cast(qual(typeof(exp))exp. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 11 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11722 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Resolution| |FIXED -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 11 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11722 PST --- I disagree. That was not necessary, unless you prove otherwise. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 11 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11722This is a spin-off issue from bug 5747. D has a cast syntax for modifying just only the type qualifier of the operand. http://dlang.org/expression#CastExpression CastExpression: cast ( Type ) UnaryExpression cast ( CastQual ) UnaryExpression <-- cast ( ) UnaryExpression <--Kenji: I'm wondering: Your original post seemed to imply the enhancement was *only* for qualifier cast. However, the final result seems to be for *any* kind of cast, whith matching types. I mean: const(S) s; auto a = cast() s; auto b = cast(S) s; In the case of "a": We have a "CastQual" type cast, and this bypasses the opCast operator entirelly. In the case of "b": We have a *Type* cast, but that happens to result only in a qualifier change. In the case of "b", *should* we call opCast? Please clarify. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 12 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11722Yes. And actually, with git-head, following code asserts only in the case of "b". struct S { T opCast(T)() const { assert(0); } } void main() { const(S) s; auto a = cast() s; // bypass opCast auto b = cast(S) s; // call opCast and assert } -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------This is a spin-off issue from bug 5747. D has a cast syntax for modifying just only the type qualifier of the operand. http://dlang.org/expression#CastExpression CastExpression: cast ( Type ) UnaryExpression cast ( CastQual ) UnaryExpression <-- cast ( ) UnaryExpression <--Kenji: I'm wondering: Your original post seemed to imply the enhancement was *only* for qualifier cast. However, the final result seems to be for *any* kind of cast, whith matching types. I mean: const(S) s; auto a = cast() s; auto b = cast(S) s; In the case of "a": We have a "CastQual" type cast, and this bypasses the opCast operator entirelly. In the case of "b": We have a *Type* cast, but that happens to result only in a qualifier change. In the case of "b", *should* we call opCast? Please clarify.
Dec 12 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11722Ah. Oops. I was testing the wrong code. Thanks. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Yes. And actually, with git-head, following code asserts only in the case of "b".This is a spin-off issue from bug 5747. D has a cast syntax for modifying just only the type qualifier of the operand. http://dlang.org/expression#CastExpression CastExpression: cast ( Type ) UnaryExpression cast ( CastQual ) UnaryExpression <-- cast ( ) UnaryExpression <--Kenji: I'm wondering: Your original post seemed to imply the enhancement was *only* for qualifier cast. However, the final result seems to be for *any* kind of cast, whith matching types. I mean: const(S) s; auto a = cast() s; auto b = cast(S) s; In the case of "a": We have a "CastQual" type cast, and this bypasses the opCast operator entirelly. In the case of "b": We have a *Type* cast, but that happens to result only in a qualifier change. In the case of "b", *should* we call opCast? Please clarify.
Dec 12 2013