2 ms·
I wonder how much heartache it would be for the next revision of the C standard to go: Integers behave as if they were two's complement for all overflow behavio
by jandrese 8y ago
I wonder how much heartache it would be for the next revision of the C standard to go: Integers behave as if they were two's complement for all overflow behavior.
It's already true in just about every system in the world today, and people with extremely obscure hardware can just hack a workaround into their compiler (or straight up ignore the standard because they're just a handful of people anyway).
I get that back in the day the K&R didn't want to impose on the hardware vendors and left the standard vague where they had different ideas, but that doesn't mean you can't evolve the standard as the hardware evolves over the decades.
- loup-vaillant 8y agoWhy is this getting downvoted? It sounds very reasonable to me. It wouldn't even be the first time C breaks compatibility (I'm thinking of strict aliasing).
- jandrese 8y agoIt doesn't even break compatibility. It just defines and area that was previously left undefined. It would only break things that were relying on undefined behavior.
- loup-vaillant 8y agoIt wouldn't break overflow, but it would break the conversion to and from signed negative integers (which if I recall correctly is implementation defined, and behaves differently on 1's complement and sign & magnitude platforms —if there are any left).