projects
/
web.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
avoid UB by using + instead of array indexing
[web.git]
/
personal
/
_posts
/
2018-07-24-pointers-and-bytes.md
diff --git
a/personal/_posts/2018-07-24-pointers-and-bytes.md
b/personal/_posts/2018-07-24-pointers-and-bytes.md
index 53daa57ce3a5a065bd35b39f51418eb2c144a321..85ba4aa679a615069221de05d17dc6a94a9f9669 100644
(file)
--- a/
personal/_posts/2018-07-24-pointers-and-bytes.md
+++ b/
personal/_posts/2018-07-24-pointers-and-bytes.md
@@
-56,7
+56,7
@@
int test() {
auto x = new int[8];
auto y = new int[8];
y[0] = 42;
auto x = new int[8];
auto y = new int[8];
y[0] = 42;
- auto x_ptr =
&x[8]
; // one past the end
+ auto x_ptr =
x+8
; // one past the end
if (x_ptr == &y[0])
*x_ptr = 23;
return y[0];
if (x_ptr == &y[0])
*x_ptr = 23;
return y[0];