Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
September 19, 2018 [Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17729 er.krali@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |er.krali@gmail.com --- Comment #1 from er.krali@gmail.com --- Furthermore, it doesn't work with ref parameters either: --- struct S { int i; } void fun(ref S s, int i) { s.i = i; } void main() { shared S s; /* This fails: onlineapp.d(17): Error: function onlineapp.fun(ref S s, int i) is not callable using argument types (S, int) onlineapp.d(17): cannot pass rvalue argument cast(S)s of type S to parameter ref S s fun(cast(S) s, 1); */ (*(cast (S*) &s)).fun(1); // Nasty workaround assert (s.i == 1); } --- I also can't understand why the workaround works at all, the result of dereferencing a pointer should surely be a rvalue? Is that also a bug? -- |
September 19, 2018 [Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17729 --- Comment #2 from ag0aep6g <ag0aep6g@gmail.com> --- (In reply to er.krali from comment #1) > I also can't understand why the workaround works at all, the result of dereferencing a pointer should surely be a rvalue? > > Is that also a bug? Dereferencing a pointer gives an lvalue. If it gave an rvalue, pointers would be pretty useless. You couldn't assign through them. If you disagree or have more questions on this, I'd suggest making a thread on D.learn [1]. We're going off topic here. [1] https://forum.dlang.org/group/learn -- |
September 19, 2018 [Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17729 --- Comment #3 from er.krali@gmail.com --- (In reply to ag0aep6g from comment #2) > Dereferencing a pointer gives an lvalue. If it gave an rvalue, pointers would be pretty useless. You couldn't assign through them. > > If you disagree or have more questions on this, I'd suggest making a thread on D.learn [1]. We're going off topic here. > > > [1] https://forum.dlang.org/group/learn Sure, now that I think about it, it seems indeed obvious, sorry for the OT. -- |
March 19, 2019 [Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17729 ag0aep6g <ag0aep6g@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://issues.dlang.org/sh | |ow_bug.cgi?id=19754 -- |
March 26, 2019 [Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17729 Andrei Alexandrescu <andrei@erdani.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrei@erdani.com Assignee|nobody@puremagic.com |razvan.nitu1305@gmail.com -- |
May 25, 2019 [Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17729 ag0aep6g <ag0aep6g@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |DUPLICATE --- Comment #4 from ag0aep6g <ag0aep6g@gmail.com> --- This has apparently been fixed by the fix for issue 19754. `auto p = & cast(S) s;` compiles now. Closing as duplicate. *** This issue has been marked as a duplicate of issue 19754 *** -- |
Copyright © 1999-2021 by the D Language Foundation