*sigh* gcc <8 UBSan fails to catch this serious, trivial-to-make error:https://godbolt.org/z/kNil_u
-
-
&a+1 is legal b/c it points one past the end?
-
Yes, legal for any a which is itself legal, but illegal to dereference.
-
Oh, I thought only "one past the end of a variable "a" explicitly declared as an array" was a legal pointer. I didn't know it applied to all legal "a".
-
6.5.6 Additive operators ¶7: "For the purposes of these operators, a pointer to an object that is not an element of an array behaves the same as a pointer to the first element of an array of length one with the type of the object as its element type."
End of conversation
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.