On Fri, 9 Feb 2024 at 11:10, Nick Desaulniers <ndesaulniers@xxxxxxxxxx> wrote: > > I have 100% observed llvm throw out writes to objects declared as > const where folks tried to write via "casting away the const" (since > that's UB) which resulted in boot failures in the Linux kernel > affecting android devices. *PLEASE* fix compilers that silently generate bogus code just because it's UB. That's pure and utter garbage. We want a compiler flag that says "don't do that idiotic sh*t". There are very good reasons why Linux uses flags like -fno-strict-overflow -fno-strict-aliasing -fno-delete-null-pointer-checks and that reason is that the ANSI C standards committee has had its head up its arse when it comes to these areas. Optimizations based on undefined behavior are wrong. If you have to resort to those kinds of optimizations, your compiler is bad. *Silently* doing so is even worse. If the compiler decides "I will throw away this write because it's UB", I want a warning. Better yet, I'd like to see compiler writers admit that undefined behavior was not a good language feature in the first place, and that any time the standard says "that's undefined behavior", you ignore that bogus standards language, and you turn it into "implementation defined", possibly with a warning. Linus