Skip to content

Fix pointers passed to rules that expect references - #636

Merged
nunoplopes merged 5 commits into
Cpp2Rust:masterfrom
lucic71:49-pointer-reference-rule-args
Nov 18, 2026
Merged

nunoplopes merged 5 commits into
Cpp2Rust:masterfrom
lucic71:49-pointer-reference-rule-args

Conversation

@lucic71

@lucic71 lucic71 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Pointers were dereferenced before being passed to reference arguments, that's wrong. This PR passes the pointers without dereferencing them.

assert!(
({
({
(if CppLess::less(&high.as_pointer(), &low.as_pointer()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not correct. It should be comparing the pointers themselves, not the pointer to the pointer.
should be less(*high.borrow(), *low.borrow())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is exactly what the PR fixes. CppLess receives reference (Ptr), low and high are themselves Ptr, so the input is Ptr<Ptr<T>>. Inside CppLess the pointer is dereferenced: lhs.with(|a| rhs.with(|b| a < b))

@nunoplopes
nunoplopes merged commit 8cc028c into Cpp2Rust:master Nov 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants