Commit d5786bc
committed
Merge bitcoin/bitcoin#32490: refactor: Remove UB in prevector reverse iterators
faf9082 test: Fix whitespace in prevector_tests.cpp (MarcoFalke)
fa7f04c refactor: Remove UB in prevector reverse iterators (MarcoFalke)
Pull request description:
`rend()` creates a pointer with offset `-1`. This is UB, according to the C++ standard: https://eel.is/c++draft/expr.add#4:
When an expression J that has integral type is added to [...] an
expression P of pointer type, the result has the type of P.
... if P points to a (possibly-hypothetical) array element i of an
array object x with n elements [...] the expressions P + J and J + P
(where J has the value j) point to the (possibly-hypothetical) array
element i+j of x if 0≤i+j≤n [...]
Otherwise, the behavior is undefined.
Also, it is unclear why the functions exist at all, when stdlib utils such as `std::reverse_iterator{it}` or `std::views::reverse` can be used out of the box.
So remove them, along with the ubsan suppressions, that are no longer used.
I've tagged this a refactor, because the code was always dead (unused outside of tests). And since commit 2925bd5 it was completely dead. Also, I could not find a sanitizer that detects this type of UB.
ACKs for top commit:
l0rinc:
tested ACK faf9082
achow101:
ACK faf9082
stickies-v:
ACK faf9082, nice find.
theuni:
utACK faf9082
Tree-SHA512: 31511d520a1c0fdd65c2e5f1a8ef6fd17464303b6bff88a5d9d9577adfee849d431deb510882b6f4e15e8fb7168861bc0d26fca3bed4278f57a9d6e7b1235dceFile tree
3 files changed
+58
-84
lines changed- src
- test
- test/sanitizer_suppressions
3 files changed
+58
-84
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | 80 | | |
101 | 81 | | |
102 | 82 | | |
| |||
129 | 109 | | |
130 | 110 | | |
131 | 111 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | 112 | | |
154 | 113 | | |
155 | 114 | | |
| |||
304 | 263 | | |
305 | 264 | | |
306 | 265 | | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | 266 | | |
313 | 267 | | |
314 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | | - | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
63 | | - | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
79 | | - | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
87 | | - | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
93 | 97 | | |
94 | 98 | | |
95 | | - | |
| 99 | + | |
| 100 | + | |
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
99 | 104 | | |
100 | 105 | | |
101 | | - | |
| 106 | + | |
| 107 | + | |
102 | 108 | | |
103 | 109 | | |
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
107 | | - | |
108 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
109 | 116 | | |
110 | 117 | | |
111 | 118 | | |
112 | 119 | | |
113 | 120 | | |
114 | | - | |
| 121 | + | |
| 122 | + | |
115 | 123 | | |
116 | 124 | | |
117 | 125 | | |
118 | 126 | | |
119 | 127 | | |
120 | | - | |
| 128 | + | |
| 129 | + | |
121 | 130 | | |
122 | 131 | | |
123 | 132 | | |
124 | 133 | | |
125 | 134 | | |
126 | | - | |
| 135 | + | |
| 136 | + | |
127 | 137 | | |
128 | 138 | | |
129 | 139 | | |
130 | 140 | | |
131 | 141 | | |
132 | | - | |
| 142 | + | |
| 143 | + | |
133 | 144 | | |
134 | 145 | | |
135 | 146 | | |
136 | 147 | | |
137 | 148 | | |
138 | | - | |
| 149 | + | |
| 150 | + | |
139 | 151 | | |
140 | 152 | | |
141 | 153 | | |
142 | 154 | | |
143 | 155 | | |
144 | | - | |
| 156 | + | |
| 157 | + | |
145 | 158 | | |
146 | 159 | | |
147 | 160 | | |
148 | 161 | | |
149 | | - | |
| 162 | + | |
| 163 | + | |
150 | 164 | | |
151 | 165 | | |
152 | 166 | | |
153 | 167 | | |
154 | | - | |
| 168 | + | |
| 169 | + | |
155 | 170 | | |
156 | 171 | | |
157 | 172 | | |
158 | | - | |
| 173 | + | |
| 174 | + | |
159 | 175 | | |
160 | 176 | | |
161 | 177 | | |
162 | | - | |
| 178 | + | |
| 179 | + | |
163 | 180 | | |
164 | 181 | | |
165 | 182 | | |
| |||
171 | 188 | | |
172 | 189 | | |
173 | 190 | | |
174 | | - | |
| 191 | + | |
| 192 | + | |
175 | 193 | | |
176 | 194 | | |
177 | 195 | | |
178 | 196 | | |
179 | 197 | | |
180 | 198 | | |
181 | | - | |
| 199 | + | |
| 200 | + | |
182 | 201 | | |
183 | 202 | | |
184 | 203 | | |
185 | 204 | | |
186 | | - | |
| 205 | + | |
| 206 | + | |
187 | 207 | | |
188 | 208 | | |
189 | 209 | | |
| |||
203 | 223 | | |
204 | 224 | | |
205 | 225 | | |
206 | | - | |
| 226 | + | |
| 227 | + | |
207 | 228 | | |
208 | 229 | | |
209 | 230 | | |
210 | | - | |
| 231 | + | |
| 232 | + | |
211 | 233 | | |
212 | 234 | | |
213 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | | - | |
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
| |||
0 commit comments