#include <iostream>
#include <cmath>
#define max(x,y) (x)>(y)? (x): (y)
int main() {
int i = 10;
int j = 5;
int k = 0;
k = max(i++,++j);
std::cout << i << "\t" << j << "\t" << k << std::endl;
}
#include <iostream> #include <cmath> #define max(x,y) (x)>(y)? (x): (y) int main() { int i
Share
No, it doesn’t.
In this case the situation is saved by the fact the
?:operator has a sequence point immediately after evaluating the first operand (the condition) and after that only one of the two expressions (second or third operand) is evaluated. Your code is equivalent toNo undefined behavior here.