News for hackers. Stuff that matters.
Re:Signed Integers Are Two’s Complement by GlitchMr on Thursday May 31, 2018 @06:52AM (#17195370)
I like the idea of forbidding signed integer representations other than 2's complement, as it is de facto standard, pretty much nobody makes CPUs with non-standard integer representations, partly due to C programs assuming 2's complement integer representation.

What I don't like about this proposal is defining signed integer overflow as 2's complement wrapping. Yes, yes, I know undefined behaviour is evil, and programs wouldn't become much slower. However, if a program has signed overflow, it's likely a bug anyway. Defining signed overflow as 2's complement wrapping would mean not allowing other behaviours, in particular, trapping. On architectures with optional overflow traps (most architectures not called x86 or ARM), trapping would be much more preferable to quiet bugs. Meanwhile, while it is undefined behaviour, the implementation would be still free to define it, for instance in GCC it can be done with `-fwrapv`.

Re:Signed Integers Are Two’s Complement by loup-vaillant on Thursday May 31, 2018 @08:08AM (#17195680)
> However, if a program has signed overflow, it's likely a bug anyway.

There are programs that check for overflow after the fact. Is that a bug?

Re:Signed Integers Are Two’s Complement by sanxiyn on Thursday May 31, 2018 @10:12AM (#17196425)
No, but since most overflows are bugs, I think the right solution is to standardize something like GCC's __builtin_add_overflow for overflow checks. Rust does this.
Re:Signed Integers Are Two’s Complement by dEnigma on Thursday May 31, 2018 @08:04AM (#17195675)
Seems like this was changed in more recent revisions, according to another comment:

The main change between [P0907r0] and the subsequent revision is to maintain undefined behavior when signed integer overflow occurs, instead of defining wrapping behavior.