https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116690
--- Comment #4 from Yunbo Ni <yunboni at smail dot nju.edu.cn> --- (In reply to Andrew Pinski from comment #3) > Note in C++, it is undefined at the point of return in a rather than > afterwards. > > Also note PR 104690 is filed about catching this with -fsanitize=undefined. > > Note also clang has a similar behavior as GCC on the different optimization > levels and also does not catch it either with -fsanitize=undefined. Thanks for your kind and detailed explanation! BTW, when I change the value of b to 1 in line 3 and compiled this code with -O0 flag, it gets killed with with processing time exceeded. Is this also due to the undefined behavior?