That's the only way to use C correctly.
Alas, it's nearly impossible to write any non-trivial C code that doesn't have UB.
Re:GCC undefined behaviors are getting wild
by pjc50 on Monday November 28, 2022 @04:30AM
(#33771446)
"a+b" for signed integer types potentially invokes undefined behavior (overflow). It's a horrendous situation.
I would simply not depend on invoking UB as part of my program's behavior (?).