When attempting to pre-increment a pointer to a struct, compiler throws error that operation is not between arithmetic types or a pointer operation.
Code
typedef struct {
int i;
} s;
int main() {
s *x;
++x;
}
Error
struct.c:7:3 error: invalid program: invalid operators for '+' (expected either arithmetic types or pointer operation, got 'struct {
int i;
} * + struct {
int i;
} *'
++x;
^^
1 error generated
Potential cause of error, paraphrasing @jyn514 here: It thinks that it's adding a 1 of type pointer, but it's adding a 1 of type integer here. This is a bug in desugaring complex assignment then here. It needs to be smart and only cast if it would be valid.
When attempting to pre-increment a pointer to a struct, compiler throws error that operation is not between arithmetic types or a pointer operation.
Code
Error
Potential cause of error, paraphrasing @jyn514 here: It thinks that it's adding a
1
of type pointer, but it's adding a1
of type integer here. This is a bug in desugaring complex assignment then here. It needs to be smart and only cast if it would be valid.