Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up`nocapture` attribute is missing on function arguments #25759
Comments
dotdash
added
the
A-codegen
label
May 24, 2015
This comment has been minimized.
This comment has been minimized.
|
I briefly discussed this with @eddyb on irc the other day, and the way we used to set fn foo(x: &i32) -> *const i32 {
x as *const i32
}Since we based the attribute purely on the fact that the pointer has an anonymous lifetime, I assume we don't want to have UB in safe code, right? That would mean that we need to perform some analysis on the function body to determine which attributes we can emit and that we need to emit those attributes in the metadata, because other crates can't necessarilly perform this analysis, because they don't have access to the function body at all. |
This comment has been minimized.
This comment has been minimized.
|
What are the benefits of applying the |
This comment has been minimized.
This comment has been minimized.
|
LLVM seems to be inferring the |
This comment has been minimized.
This comment has been minimized.
|
@ranma LLVM can't do that for external functions though. We'd still have to store the information in the crate metadata, even if we don't perform the analysis ourselves and just inspect what LLVM could infer. |
brson
added
I-slow
T-compiler
labels
Jun 1, 2017
This comment has been minimized.
This comment has been minimized.
|
In the absence of clearer unsafe code guidelines, it is not clear when we should add this attribute anyhow. |
brson
added
A-LLVM
P-low
and removed
A-LLVM
labels
Jun 1, 2017
This comment has been minimized.
This comment has been minimized.
|
Wishlist. If somebody ever figures it out, great. |
dotdash commentedMay 24, 2015
In a function like
fn foo(x: &i32), the pointer is known not to be captured by the function because its lifetime doesn't allow it. We used to emit thenocaptureattribute for such function arguments but don't do so anymore.