From c2d7f74af551223ec826ee8bbbefc6a67ede9fdb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 13 May 2026 20:21:10 +0000 Subject: [PATCH 1/2] Replace offset(1) pointer increments with += 1 Agent-Logs-Url: https://github.com/Cpp2Rust/cpp2rust/sessions/4292d6f5-f28a-4fb3-9f45-3a67ee6f91c7 Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com> --- libcc2rs/src/inc.rs | 8 ++++---- libcc2rs/src/io.rs | 4 ++-- libcc2rs/src/rc.rs | 2 +- rules/algorithm/tgt_unsafe.rs | 4 ++-- rules/stdio/tgt_refcount.rs | 2 +- rules/stdio/tgt_unsafe.rs | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libcc2rs/src/inc.rs b/libcc2rs/src/inc.rs index a3433469..16b47aad 100644 --- a/libcc2rs/src/inc.rs +++ b/libcc2rs/src/inc.rs @@ -87,7 +87,7 @@ impl UnsafePostfixInc for *const T { #[inline] unsafe fn postfix_inc(&mut self) -> Self { let copy = *self; - *self = self.offset(1); + *self += 1; copy } } @@ -96,7 +96,7 @@ impl UnsafePostfixInc for *mut T { #[inline] unsafe fn postfix_inc(&mut self) -> Self { let copy = *self; - *self = self.offset(1); + *self += 1; copy } } @@ -111,7 +111,7 @@ pub trait UnsafePrefixInc { impl UnsafePrefixInc for *const T { #[inline] unsafe fn prefix_inc(&mut self) -> Self { - *self = self.offset(1); + *self += 1; *self } } @@ -119,7 +119,7 @@ impl UnsafePrefixInc for *const T { impl UnsafePrefixInc for *mut T { #[inline] unsafe fn prefix_inc(&mut self) -> Self { - *self = self.offset(1); + *self += 1; *self } } diff --git a/libcc2rs/src/io.rs b/libcc2rs/src/io.rs index a9f3ce49..87312a52 100644 --- a/libcc2rs/src/io.rs +++ b/libcc2rs/src/io.rs @@ -112,7 +112,7 @@ pub fn fread_refcount(a0: AnyPtr, a1: u64, a2: u64, a3: Ptr<::std::fs::File>) -> for &byte in &buffer[..n] { dst.write(byte); - dst = dst.offset(1); + dst += 1; } read_bytes += n; @@ -154,7 +154,7 @@ pub unsafe fn fread_unsafe( for &byte in &buffer[..n] { unsafe { *dst = byte; - dst = dst.offset(1); + dst += 1; } } diff --git a/libcc2rs/src/rc.rs b/libcc2rs/src/rc.rs index 63f1942b..877e73fd 100644 --- a/libcc2rs/src/rc.rs +++ b/libcc2rs/src/rc.rs @@ -641,7 +641,7 @@ impl Iterator for StringIterator { // skip the null terminator if self.ptr.get_offset() + 1 < self.ptr.len() { let value = self.ptr.clone(); - self.ptr = self.ptr.offset(1); + self.ptr += 1; Some(value) } else { None diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index 848fe4c6..76ce8cac 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -13,8 +13,8 @@ unsafe fn f2>(a0: *const T1, a1: *const T1, a2: *mut T2) let mut curr = a0.clone(); while curr < a1 { *outptr = (*curr).clone().into(); - curr = curr.offset(1); - outptr = outptr.offset(1); + curr += 1; + outptr += 1; } outptr } diff --git a/rules/stdio/tgt_refcount.rs b/rules/stdio/tgt_refcount.rs index 4c2e0a60..89df4a87 100644 --- a/rules/stdio/tgt_refcount.rs +++ b/rules/stdio/tgt_refcount.rs @@ -80,7 +80,7 @@ fn f6(a0: AnyPtr, a1: u64, a2: u64, a3: Ptr<::std::fs::File>) -> u64 { for i in 0..to_fill { buffer[i] = src.read(); - src = src.offset(1); + src += 1; } let mut off = 0; diff --git a/rules/stdio/tgt_unsafe.rs b/rules/stdio/tgt_unsafe.rs index 737728b9..688f7c7d 100644 --- a/rules/stdio/tgt_unsafe.rs +++ b/rules/stdio/tgt_unsafe.rs @@ -85,7 +85,7 @@ unsafe fn f6(a0: *const ::libc::c_void, a1: u64, a2: u64, a3: *mut ::std::fs::Fi for i in 0..to_fill { buffer[i] = *src; - src = src.offset(1); + src += 1; } let mut off = 0; From 9ad78e66dda54fe0b02dde9525c12ca55703ce59 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 13 May 2026 21:33:34 +0100 Subject: [PATCH 2/2] fix build --- libcc2rs/src/inc.rs | 8 ++++---- libcc2rs/src/io.rs | 2 +- rules/algorithm/tgt_unsafe.rs | 4 ++-- rules/stdio/tgt_refcount.rs | 2 +- rules/stdio/tgt_unsafe.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libcc2rs/src/inc.rs b/libcc2rs/src/inc.rs index 16b47aad..a3433469 100644 --- a/libcc2rs/src/inc.rs +++ b/libcc2rs/src/inc.rs @@ -87,7 +87,7 @@ impl UnsafePostfixInc for *const T { #[inline] unsafe fn postfix_inc(&mut self) -> Self { let copy = *self; - *self += 1; + *self = self.offset(1); copy } } @@ -96,7 +96,7 @@ impl UnsafePostfixInc for *mut T { #[inline] unsafe fn postfix_inc(&mut self) -> Self { let copy = *self; - *self += 1; + *self = self.offset(1); copy } } @@ -111,7 +111,7 @@ pub trait UnsafePrefixInc { impl UnsafePrefixInc for *const T { #[inline] unsafe fn prefix_inc(&mut self) -> Self { - *self += 1; + *self = self.offset(1); *self } } @@ -119,7 +119,7 @@ impl UnsafePrefixInc for *const T { impl UnsafePrefixInc for *mut T { #[inline] unsafe fn prefix_inc(&mut self) -> Self { - *self += 1; + *self = self.offset(1); *self } } diff --git a/libcc2rs/src/io.rs b/libcc2rs/src/io.rs index 87312a52..32c11623 100644 --- a/libcc2rs/src/io.rs +++ b/libcc2rs/src/io.rs @@ -154,7 +154,7 @@ pub unsafe fn fread_unsafe( for &byte in &buffer[..n] { unsafe { *dst = byte; - dst += 1; + dst = dst.offset(1); } } diff --git a/rules/algorithm/tgt_unsafe.rs b/rules/algorithm/tgt_unsafe.rs index 76ce8cac..848fe4c6 100644 --- a/rules/algorithm/tgt_unsafe.rs +++ b/rules/algorithm/tgt_unsafe.rs @@ -13,8 +13,8 @@ unsafe fn f2>(a0: *const T1, a1: *const T1, a2: *mut T2) let mut curr = a0.clone(); while curr < a1 { *outptr = (*curr).clone().into(); - curr += 1; - outptr += 1; + curr = curr.offset(1); + outptr = outptr.offset(1); } outptr } diff --git a/rules/stdio/tgt_refcount.rs b/rules/stdio/tgt_refcount.rs index 89df4a87..4c2e0a60 100644 --- a/rules/stdio/tgt_refcount.rs +++ b/rules/stdio/tgt_refcount.rs @@ -80,7 +80,7 @@ fn f6(a0: AnyPtr, a1: u64, a2: u64, a3: Ptr<::std::fs::File>) -> u64 { for i in 0..to_fill { buffer[i] = src.read(); - src += 1; + src = src.offset(1); } let mut off = 0; diff --git a/rules/stdio/tgt_unsafe.rs b/rules/stdio/tgt_unsafe.rs index 688f7c7d..737728b9 100644 --- a/rules/stdio/tgt_unsafe.rs +++ b/rules/stdio/tgt_unsafe.rs @@ -85,7 +85,7 @@ unsafe fn f6(a0: *const ::libc::c_void, a1: u64, a2: u64, a3: *mut ::std::fs::Fi for i in 0..to_fill { buffer[i] = *src; - src += 1; + src = src.offset(1); } let mut off = 0;