Skip to content

Is the address of a local variable "allocated on the stack"? #312

Open
@nikomatsakis

Description

@nikomatsakis

Code sometimes has a need to get an address from the stack — often for debugging, but sometimes for other reasons. Consider this snippet of code from rayon-rs/rayon#571:

let base = 0;
let addr = &base as *const _ as u64;

the goal here is just to get "some stack pointer" to use as a (quite weak) seed for a PRNG. This feels... sketchy to me, I thought it was worth noting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-pending-documentationStatus: The issue is "resolved," but this resolution needs documentationT-opsem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions