did you know: int foo() { int x[4] = { 0, 1, 2, 3 }; return *(x + 5 - 3); } is undefined behavior in C
-
-
@RichFelker@FioraAeterna People think that C pointers map exactly to "hardware linear address" semantics, even if it's just a common choice -
@pikhq@FioraAeterna Indeed, but if you want to consider the arithmetic well-defined then comparisons of the results are meaningless. -
@pikhq@FioraAeterna Then n>m but p+n<p+m is possible. It's cleaner and easier to specify that the arith is UB than that compar. is bogus.
End of conversation
New conversation -
-
-
@RichFelker@FioraAeterna Well it means addition / subtraction of pointers isn't associative, which is surprising & above will work anyway. -
@dotstdy@FioraAeterna It may work, or it may not. Pointer arithmetic is only associative when both forms are well-defined. -
@RichFelker@FioraAeterna And I don't see how this isn't surprising given that signed integer overflow being undefined is surprising to many
End of conversation
New conversation -
-
-
@RichFelker@FioraAeterna Not everyone develops a libc :)Thanks. Twitter will use this to make your timeline better. UndoUndo
-
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.