diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-08-24 18:57:45 +0200 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-08-24 19:05:21 +0200 |
| commit | d1ecee96bfb7fb52b67358302c524a8c0193dc23 (patch) | |
| tree | cb8e0f2ac468455b045a8d712d416e36f79807aa /src/test/incremental/thinlto | |
| parent | 490189634b656dcca9e41e6b52093569c03bd4df (diff) | |
| download | rust-d1ecee96bfb7fb52b67358302c524a8c0193dc23.tar.gz rust-d1ecee96bfb7fb52b67358302c524a8c0193dc23.zip | |
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 resulted in a crash on ARMv7 platform!
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.
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions
