projects
/
web.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6d6d619
)
avoid UB by using + instead of array indexing
author
Ralf Jung
<post@ralfj.de>
Wed, 25 Jul 2018 15:04:36 +0000
(17:04 +0200)
committer
Ralf Jung
<post@ralfj.de>
Wed, 25 Jul 2018 15:04:36 +0000
(17:04 +0200)
Thanks gnzlbg
ralf/_posts/2018-07-24-pointers-and-bytes.md
patch
|
blob
|
history
diff --git
a/ralf/_posts/2018-07-24-pointers-and-bytes.md
b/ralf/_posts/2018-07-24-pointers-and-bytes.md
index 53daa57ce3a5a065bd35b39f51418eb2c144a321..85ba4aa679a615069221de05d17dc6a94a9f9669 100644
(file)
--- a/
ralf/_posts/2018-07-24-pointers-and-bytes.md
+++ b/
ralf/_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];