Compiler used: gcc 8.2
Command line: -Wall
My current understanding of a sequence point violation is code that somehow depends on the order of evaluation of operands/sub-expressions in a given expression. This is so because the order of evaluation of operands within an expression is unspecified, as noted here. Thus, code like:
a = 5;
b = a + ++a;
is a violation and caught by -Wsequence-point as there is an ambiguity in the result, i.e. should it be (5 + 6) or (6 + 6) ? I think there is a similar ambiguity in below code as we cannot know if the the 2nd ++a will be evaluated before the 1st:
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
int use()
{
int min;
int a = 4, b = 5;
min = MIN(++a, b);
//min = ((++a) < b) ? (++a) : b;
return min;
}
I am obviously missing something as this code does not warn me on -Wseqeuence-point. Can someone please help me understand what? Note that I have deliberately defined MIN as it is.