Skip to content

Commit 4b82edd

Browse files
committed
Add comment to explain test
1 parent 4dbf126 commit 4b82edd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/unit/redundant_copy_in_conversion.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,13 @@ int main() {
55
m[0] = 1;
66
std::map<int, int>::iterator end = m.end();
77
std::map<int, int>::const_iterator const_it = m.find(0);
8+
// Comparing const_iterator with iterator forces an implicit conversion of
9+
// `end` to const_iterator. The AST shape differs between platforms:
10+
//
11+
// Linux: const_it == ConvertingCtor(end)
12+
// macOS: const_it == ConvertingCtor(CopyCtor(end))
13+
//
14+
// The extra inner CopyCtor on macOS would emit a redundant .clone() in the
15+
// generated Rust. cpp2rust suppresses it so the output matches Linux.
816
return const_it == end ? 0 : 1;
917
}

0 commit comments

Comments
 (0)