Skip to content

Commit 18127f2

Browse files
Keep repeated-append fixture arithmetic in size_t
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
1 parent 1d727cf commit 18127f2

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎tests/unit/out/refcount/string_repeat_append.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ fn main_0() -> i32 {
8383
));
8484
let mut i: usize = 0_usize;
8585
'loop_: while (i < length) {
86-
let __rhs = initial[((i as u64)
87-
.wrapping_rem((::std::mem::size_of::<[i8; 5]>() as u64)))
86+
let __rhs = initial[((i)
87+
.wrapping_rem((::std::mem::size_of::<[i8; 5]>() as usize)))
8888
as usize];
8989
(*s.borrow_mut())[i] = __rhs;
9090
i.prefix_inc();
@@ -107,8 +107,8 @@ fn main_0() -> i32 {
107107
({
108108
({ ((elem!(data, i).read()) as i32) } == {
109109
((if (i < length) {
110-
initial[((i as u64).wrapping_rem(
111-
(::std::mem::size_of::<[i8; 5]>() as u64),
110+
initial[((i).wrapping_rem(
111+
(::std::mem::size_of::<[i8; 5]>() as usize),
112112
)) as usize]
113113
} else {
114114
(*character.borrow())

‎tests/unit/out/unsafe/string_repeat_append.rs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ unsafe fn main_0() -> i32 {
7676
.collect();
7777
let mut i: usize = 0_usize;
7878
'loop_: while ((i) < (length)) {
79-
s[(i)] = initial[((i as u64)
80-
.wrapping_rem((::std::mem::size_of::<[libc::c_char; 5]>() as u64)))
81-
as usize];
79+
s[(i)] = initial[((i)
80+
.wrapping_rem((::std::mem::size_of::<[libc::c_char; 5]>() as usize)))];
8281
i.prefix_inc();
8382
}
8483
if (shrink != 0) {
@@ -95,9 +94,9 @@ unsafe fn main_0() -> i32 {
9594
assert!(
9695
(((*data.offset((i) as isize)) as i32)
9796
== ((if ((i) < (length)) {
98-
initial[((i as u64).wrapping_rem(
99-
(::std::mem::size_of::<[libc::c_char; 5]>() as u64),
100-
)) as usize]
97+
initial[((i).wrapping_rem(
98+
(::std::mem::size_of::<[libc::c_char; 5]>() as usize),
99+
))]
101100
} else {
102101
character
103102
}) as i32))

‎tests/unit/string_repeat_append.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ int main() {
1717
for (int shrink = 0; shrink < 2; ++shrink) {
1818
std::string s(length, 'x');
1919
for (std::size_t i = 0; i < length; ++i)
20-
s[i] = initial[i % sizeof(initial)];
20+
s[i] = initial[i % std::size_t(sizeof(initial))];
2121
if (shrink)
2222
s.shrink_to_fit();
2323
s.append(count, character);
2424
assert(s.size() == length + count);
2525
const char *data = s.data();
2626
for (std::size_t i = 0; i < length + count; ++i)
27-
assert(data[i] ==
28-
(i < length ? initial[i % sizeof(initial)] : character));
27+
assert(data[i] == (i < length
28+
? initial[i % std::size_t(sizeof(initial))]
29+
: character));
2930
assert(data[s.size()] == 0);
3031
++cases;
3132
}

0 commit comments

Comments
 (0)