r/C_Programming • • Oct 15 '26

Question Why are assignment expressions lvalues?

I was reading up about lvalues and understand them now as something that resolves to an address(memory location) in the program. So a variable x is an lvalue (because it is mapped to some address on the stack) and similarly *x , x[i], strings are all lvalues. But if this is the case why is an expression a = b , not an lvalue? Here the expression would assign b to a and then return a as evident in assignments like so: int c = a = b. (I know that the equals sign is right associative and hence this would get resolved as c = (a = b), but that doesn't really invalidate the fact that a = b resolves to an address in the program?)

11 Upvotes

35 comments sorted by

View all comments

1

u/ttv90 Oct 15 '26

The spec wording is always the hard part.

1

u/flatfinger Oct 16 '26

What's hard are the prerequisites: nailing down the semantics, and ensuring that other parts of the standard are consistent with them. If those things are adequately taken care of, then the wording becomes easy. If one tries to write part of the Standard without having taken care of the prerequisites, then accurate wording may seem difficult when the real problem is that correct wording is impossible.

1

u/ttv90 Oct 17 '26

Fair point, but even when the semantics are settled the wording still hurts on the reader side.

1

u/flatfinger Oct 19 '26

If people who disagree about what a standard should mean try to agree on wording, the result will either be a lot of wasted effort or worse, a "success" that is achieved by making a standard say whatever each reader wants it to say, undermining the whole point of having a standard in the first place.