News for hackers. Stuff that matters.
Re:Signed Integers Are Two’s Complement by paulddraper on Wednesday May 30, 2018 @11:10PM (#17193673)
> on x86/amd4 sizeof(int) will always be equal to 4

Nothing is stopping your C compiler from making the guarantee sizeof(int)=4 on x86/amd64.

Re:Signed Integers Are Two’s Complement by wyldfire on Wednesday May 30, 2018 @11:15PM (#17193694)
I think you are in agreement with the comment you are replying to.
Re:Signed Integers Are Two’s Complement by paulddraper on Wednesday May 30, 2018 @11:18PM (#17193711)
The comment suggested the standard make it implementation defined rather than undefined. There's not a meaningful difference here.

Even today, an implementation may define unsigned overflow.

Re:Signed Integers Are Two’s Complement by Someone on Thursday May 31, 2018 @03:48AM (#17194685)
Yes, there is. Implementation defined means that a conforming implementation _must_ document its behavior.

That means that programmers don’t have to use trial and error to figure out how the compiler behaves and don’t have to _hope_ they found all the corner cases.

Re:Signed Integers Are Two’s Complement by berti on Thursday May 31, 2018 @06:58AM (#17195395)
And that is how we get #if defined(_THIS_THING_SOME_COMPILER_DEFINES) && !defined(__BUT_NOT_THIS_ONE_THAT_COMPILER_X_DEFINES) soup ;)
Re:Signed Integers Are Two’s Complement by greenhouse_gas on Thursday May 31, 2018 @12:19PM (#17197534)
Better than than silently ignoring an if guard preventing an overflow, and then overflowing anyways on addition.
Re:Signed Integers Are Two’s Complement by wyldfire on Wednesday May 30, 2018 @11:24PM (#17193733)
Oh, I see, I wonder if greenhouse_gas is suggesting a feature similar to sizeof() that can be used to portably adapt your program's design to the target's overflow capability.
Re:Signed Integers Are Two’s Complement by unwind on Thursday May 31, 2018 @01:07AM (#17194094)
C language lawyer in training: sizeof is not a function.

The parentheses are part of the operand and only needed for type names, to make them into cast expressions.