Below are two common issues resulting in undefined behavior due to the sequence point rules:
a[i] = i++; //has a read and write between sequence points
i = i++;
An example similar to Dario's, which I've also seen people fall into:
printf("%s %s\n", inet_ntoa(&addr1), inet_ntoa(&addr2));
Not only will this either print "addr1 addr1
" or "addr2 addr2
" (because inet_ntoa
returns a pointer to a static buffer overwritten by further calls), but also it is not defined which of these will be the case (because C does not specify order of evaluation in argument lists).