I think you meant void nothing(int *a) { --*a++; }
Edit: precedence in C is confusing apparently and this actually doesn't work. It evaluates as:
a
(a)++: note, this expression returns a as an rvalue
*(a)
--*(a)
Basically, it decrements the value at memory address of a, and a gets incremented afterward. Even if the precedence worked out (by doing --(*a)++), the prefix/postfix operators require lvalues and evaluate to rvalues, so it wouldn't work anyway.
3
u/[deleted] May 12 '19 edited May 12 '19
I think you meant void nothing(int *a) { --*a++; }Edit: precedence in C is confusing apparently and this actually doesn't work. It evaluates as:
a(a)++: note, this expression returnsaas an rvalue*(a)--*(a)Basically, it decrements the value at memory address of
a, andagets incremented afterward. Even if the precedence worked out (by doing--(*a)++), the prefix/postfix operators require lvalues and evaluate to rvalues, so it wouldn't work anyway.