Turns out I know C:http://kukuruku.co/hub/programming/i-do-not-know-c …
-
-
i thought unsigned int types were specifically defined to wrap?
-
Sorry, the explanation is wrong. It's zero either way, but wrapping is mod UINT_MAX+1, not 2^(CHAR_BIT*sizeof(unsigned int)).
-
ok, yes, i see, it's the use of sizeof that's the problem.https://stackoverflow.com/questions/4475540/c-question-padding-bits-in-unsigned-integers-and-bitwise-operations-c89 …
-
also, on 11, if std doesn't specify 2's complement (don't know if it does), then evaluating -INT_MIN isn't *necessarily* ub...
-
Indeed. 2s complement with INT_MIN==-INT_MAX is also allowed by ISO C.
-
yeah, i just checked, and it allows sign-and-magnitude, in which -INT_MIN == INT_MAX is the expected behavior
-
so this brings up a funny philosophical question, which is, if something might be UB and might not be, doesn't that make it UB
-
meaningful discussions of UB only take place within the framework of specific implementation-defined parameters.
- 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.