3 ms·
> Applying the increment or decrement operators over the same variable more than once on the same line should be a compile-time error That would be nice, but d
by nayuki 5mo ago
> Applying the increment or decrement operators over the same variable more than once on the same line should be a compile-time error
That would be nice, but don't forget the more general case of pointers and aliasing:
int a = 5;
int *pa = &a;
printf("%d", (a++ + ++*pa));
The compiler cannot statically catch every possible instance of a statement where a variable is updated more than once.
- marcosdumay 5mo agoWell, aliased updates are undefined behavior already.
- deleted 5mo ago[deleted]
- not_a_bijection 5mo agoNot in C, unless at least one of the pointers were marked `restrict`.