jjzjj

anotherInt

全部标签

c++ - "warning: operation of ... may be undefined"用于三元运算——不是 if/else block

这个问题在这里已经有了答案:Undefinedbehaviorandsequencepoints(5个答案)关闭6年前。这是我的代码:intmain(){staticinttest=0;constintanotherInt=1;test=anotherInt>test?test++:0;if(anotherInt>test)test++;elsetest=0;return0;}这是我构建它时产生的警告:../main.cpp:15:40:warning:operationon‘test’maybeundefined[-Wsequence-point]test=anotherInt>te