Skip to content

No warning on returning pointer to stack #8198

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

Closed
ellistg opened this issue Mar 10, 2021 · 1 comment
Closed

No warning on returning pointer to stack #8198

ellistg opened this issue Mar 10, 2021 · 1 comment
Milestone

Comments

@ellistg
Copy link
Contributor

ellistg commented Mar 10, 2021

Was writing some benchmarks the other day and made the mistake of returning a pointer to the stack, what I did specifically was create an array or random u8's and attempted to return str[0..];, I can see now that this is incorrect but seems like something that the compiler/debug mode should warn or error.

Currently it returns the value but if you attempt to access it will just be random data. I don't know how possible this is and am fairly new to low level programming so it may just be something that is not worth having, but thought it was worth mentioning.

@Vexu
Copy link
Member

Vexu commented Mar 10, 2021

Duplicate of #2646.

@Vexu Vexu closed this as completed Mar 10, 2021
@andrewrk andrewrk added this to the 0.8.0 milestone Jun 4, 2021
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

No branches or pull requests

3 participants