On Thu, Jul 13, 2023 at 03:55:55PM +0800, linke li wrote: > > So we're adding code to handle eventual future compiler bugs? That sounds > > wrong, but maybe I misunderstood the problem you are trying to solve? > > Sorry for not making it clear. My focus is the presence of undefined > behavior in kernel code. > Compilers can generate any code for undefined behavior and compiler > developers will not > take this as compiler bugs. In my option, kernel should not have > undefined behavior. The point that several people have tried to make to you is that *this is not undefined behaviour*. The kernel is compiled with -fno-strict-overflow which causes the compiler to define signed arithmetic overflow to behave as twos-complement. Check the gcc documentation.