diff options
| author | bors <bors@rust-lang.org> | 2016-08-27 07:52:20 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-27 07:52:20 -0700 |
| commit | 11946956a6352f49c6aadc1c13c39757a046e0c2 (patch) | |
| tree | d7ba57b9dc0cffaab49aaa505c028d1ef1a5553f /src/test/incremental/thinlto | |
| parent | 099b9fdb1a170b57ffd7174b3c3042cc86b7fe91 (diff) | |
| parent | 8295c5056da0be355c86b29d1d4eed469920e73c (diff) | |
| download | rust-11946956a6352f49c6aadc1c13c39757a046e0c2.tar.gz rust-11946956a6352f49c6aadc1c13c39757a046e0c2.zip | |
Auto merge of #35969 - bluss:memrchr-alignment, r=nagisa
memrchr: Correct aligned offset computation
The memrchr fallback did not compute the offset correctly. It was
intentioned to land on usize-aligned addresses but did not.
This was suspected to have resulted in a crash on ARMv7!
This bug affected non-linux platforms.
I think like this, if we have a slice with pointer `ptr` and length
`len`, we want to find the last usize-aligned offset in the slice.
The correct computation should be:
For example if ptr = 1 and len = 6, and `size_of::<usize>()` is 4:
```
[ x x x x x x ]
1 2 3 4 5 6
^-- last aligned address at offset 3 from the start.
```
The last aligned address is ptr + len - (ptr + len) % usize_size.
Compute offset from the start as:
offset = len - (ptr + len) % usize_size = 6 - (1 + 6) % 4 = 6 - 3 = 3.
I believe the function's return value was always correct previously, if
the platform supported unaligned addresses.
Fixes #35967
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions
