On Fri, Jul 18, 2025 at 06:04:32PM +0200, Florian Weimer wrote: > While this is true in principle, it's not how -fwrapv (or undefined signed > overflow) is implemented in GCC. When writing optimizations, you have > to be careful not to introduce signed overflow that was not present in > the original code because there aren't separate tree operations for > wrapping and overflowing operations. I have no idea what Gimple does here. But in RTL bits are bits, and this is defined fine. "Signed" does not exist for most things. > It's standard-conforming, but GCC forgoes a lot of optimization > opportunities as a result. Like not doing -fwrapv by default, this > breaks quite a bit of code, of course. It's also a missed opportunity > for telling more programmers that they can't write correct C code. Haha! But we (== GCC developers) do not feel like we need to tell any obvious facts to anyone all the time. Would it make the world a better world if we did? We do do what the user expects in most trivial cases, where doing that does not hurt anyone. We want the compiler to be useful to most developers! But that sometimes means *not* doing what a particular naive user (who doe not know C so well) expects. Sometimes we give a warning then. Segher