[Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts

2019-05-25 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17729

ag0aep6g  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #4 from ag0aep6g  ---
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 ***

--


[Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts

2019-03-26 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17729

Andrei Alexandrescu  changed:

   What|Removed |Added

 CC||and...@erdani.com
   Assignee|nob...@puremagic.com|razvan.nitu1...@gmail.com

--


[Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts

2019-03-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17729

ag0aep6g  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=19754

--


[Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts

2018-09-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17729

--- Comment #3 from er.kr...@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.

--


[Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts

2018-09-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17729

--- Comment #2 from ag0aep6g  ---
(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

--


[Issue 17729] dmd says cast expression is "not an lvalue", but it can be used as one in other contexts

2018-09-19 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17729

er.kr...@gmail.com changed:

   What|Removed |Added

 CC||er.kr...@gmail.com

--- Comment #1 from er.kr...@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*) )).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?

--