3 ms·
If foo is an lvalue, then I believe (for example) *(foo[0].bar->baz) is also an lvalue, and those pointer dereferences can go anywhere. Those values occupy
by dbaupp 8y ago
If foo is an lvalue, then I believe (for example)
*(foo[0].bar->baz)
is also an lvalue, and those pointer dereferences can go anywhere. Those values occupy a location in memory, as you said, even if it isn't on the stack.
- leetcrew 8y agooh okay, understood. frankly I don't have an airtight understanding of the c++ standards and I would have considered your expression to be a dereference operation on an lvalue, but not an lvalue itself. ty for the explanation!
- simiones 8y agoI'm sure there are some complex exceptions, but as a starter, you can think of lvalues as "anything you can assign to" (the l basically stands for left, as in, "can appear on the left of an assignment"). So, if you have something like `foo(val) = 10`, then `foo(val)` is an lvalue.
- mannykannot 8y agoOne of the complications is that if you take an l-value and const-qualify it, it is still an l-value (but not a modifiable l-value.) https://www.geeksforgeeks.org/lvalue-and-rvalue-in-c-language/ https://www.geeksforgeeks.org/lvalue-and-rvalue-in-c-languag...
- mannykannot 8y agoThey are not mutually exclusive. When a pointer has been set to point to an lvalue, dereferencing it yields that lvalue.