News for hackers. Stuff that matters.
Re:Signed Integers Are Two’s Complement by dzdt on Thursday May 31, 2018 @08:46AM (#17195852)
If a signed operation would naturally produce a value that is not within the range of the result type, the behavior is undefined. The author had hoped to make this well-defined as wrapping (the operations produce the same value bits as for the corresponding unsigned type), but WG21 had strong resistance against this.

Who are the standards committee people having strong resistance against this, and what in the world is their argument?

Re:Signed Integers Are Two’s Complement by kazinator on Thursday May 31, 2018 @08:59AM (#17195921)
Undefined doesn't mean incorrect; it's just the absence of a requirement. A compiler writer can add requirements locally (like "signed integer overflows have wrapping behavior") that are missing in the standard.

The standard is not a suitable babysitting tool for GCC maintainers, which is what I suspect is the motivation here.

Re:Signed Integers Are Two’s Complement by yoklov on Thursday May 31, 2018 @09:26AM (#17196090)
This isn’t entirely untrue in theory, but in practice it is. Compilers optimize under the assumption that undefined behavior never occurs, and the standard is written with this assumption. Any conforming compiler is free to break code that relies on this.

Typically, behavior that reasonably may vary from compiler/machine is considered implementation defined, and not undefined.

Re:Signed Integers Are Two’s Complement by kazinator on Thursday May 31, 2018 @09:51AM (#17196272)
> Any conforming compiler is free to break code that relies on this.

Ah, but, for example, __attribute__((packed)) is undefined behavior; is the compiler free to break that?

This "free to break" is a juvenile fiction based on the idea that the only document that applies is ISO C; there is no other contract or promise between user and implementor.

Re:Signed Integers Are Two’s Complement by sanxiyn on Thursday May 31, 2018 @10:03AM (#17196360)
GCC documentation is another such contract, which provides -fwrapv. If you want -fwrapv, use -fwrapv.
Re:Signed Integers Are Two’s Complement by sanxiyn on Thursday May 31, 2018 @10:01AM (#17196348)
I am not sure why people pick GCC in particular for this issue. LLVM does exactly the same.