Commit f52318b
committed
Fix a strict aliasing violation in map and unordered_map.
These containers type-punned between pair<K, V> and pair<const K, V> as an
optimization. This commit instead provides access to the pair via a pair of
references that assign through to the underlying object. It's still undefined to
mutate a const object, but clang doesn't optimize on this for data members, so
this should be safe.
Differential revision: https://reviews.llvm.org/D47607
llvm-svn: 3339481 parent ba81d7f commit f52318b
4 files changed
Lines changed: 177 additions & 89 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | 35 | | |
40 | 36 | | |
41 | | - | |
42 | 37 | | |
43 | 38 | | |
44 | 39 | | |
| |||
172 | 167 | | |
173 | 168 | | |
174 | 169 | | |
175 | | - | |
| 170 | + | |
176 | 171 | | |
177 | 172 | | |
178 | 173 | | |
| |||
184 | 179 | | |
185 | 180 | | |
186 | 181 | | |
187 | | - | |
188 | 182 | | |
189 | 183 | | |
190 | 184 | | |
| |||
198 | 192 | | |
199 | 193 | | |
200 | 194 | | |
201 | | - | |
| 195 | + | |
202 | 196 | | |
203 | 197 | | |
204 | 198 | | |
| |||
211 | 205 | | |
212 | 206 | | |
213 | 207 | | |
214 | | - | |
| 208 | + | |
215 | 209 | | |
216 | 210 | | |
217 | 211 | | |
218 | | - | |
219 | | - | |
| 212 | + | |
| 213 | + | |
220 | 214 | | |
221 | 215 | | |
222 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 40 | | |
45 | 41 | | |
46 | | - | |
47 | 42 | | |
48 | 43 | | |
49 | 44 | | |
| |||
569 | 564 | | |
570 | 565 | | |
571 | 566 | | |
572 | | - | |
573 | 567 | | |
574 | 568 | | |
575 | | - | |
| 569 | + | |
576 | 570 | | |
577 | 571 | | |
578 | 572 | | |
| |||
584 | 578 | | |
585 | 579 | | |
586 | 580 | | |
587 | | - | |
588 | 581 | | |
589 | 582 | | |
590 | 583 | | |
591 | 584 | | |
592 | 585 | | |
593 | 586 | | |
594 | | - | |
| 587 | + | |
595 | 588 | | |
596 | 589 | | |
597 | 590 | | |
| |||
605 | 598 | | |
606 | 599 | | |
607 | 600 | | |
608 | | - | |
| 601 | + | |
609 | 602 | | |
610 | 603 | | |
611 | 604 | | |
| |||
618 | 611 | | |
619 | 612 | | |
620 | 613 | | |
621 | | - | |
| 614 | + | |
622 | 615 | | |
623 | 616 | | |
624 | 617 | | |
625 | 618 | | |
626 | | - | |
627 | | - | |
| 619 | + | |
| 620 | + | |
628 | 621 | | |
629 | 622 | | |
630 | 623 | | |
| |||
0 commit comments