-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly compare unequal function pointers #581
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fn f() -> i32 { | ||
42 | ||
} | ||
|
||
fn return_fn_ptr() -> fn() -> i32 { | ||
f | ||
} | ||
|
||
fn main() { | ||
assert!(return_fn_ptr() == f); //~ ERROR assertion failed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of this test? We already test elsewhere that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just wanted to make sure we're getting the right error. But I guess the run-pass test kinda guarantees that |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fn f() -> i32 { | ||
42 | ||
} | ||
|
||
fn return_fn_ptr() -> fn() -> i32 { | ||
f | ||
} | ||
|
||
fn main() { | ||
assert!(return_fn_ptr() != f); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add this to the existing fn ptr test instead? |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not nice. :/
For once, it's not correct: A pointer into a function allocation is only in-bounds if its offset is 0.
But also, the previous behavior that
memory().check_bounds
would accept offset-0-size-0 pointers into function allocations was fully intended. These pointers are in-bounds. There is nothing wrong with a&()
pointing to a function allocation. So I don't think fixing this here is how we want to proceed.For example,
pointer_offset_inbounds
now also fails to compute a 0-offset on a function pointer. This affects every user of the oldcheck_bounds
method that was converted tomemory().get
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can reintroduce the
check_bounds
method onMemory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think that would make most sense.