rust-lang / rust-lang/reference

Are function pointers never dangling?

Open Beginner friendly
#1,967 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

https://doc.rust-lang.org/stable/reference/behavior-considered-undefined.html#r-undefined.dangling says:

A reference/pointer is “dangling” if not all of the bytes it points to are part of the same live allocation (so in particular they all have to be part of some allocation).

According to https://doc.rust-lang.org/reference/types.html#r-type.kinds

Pointer types:

  • References
  • Raw pointers
  • Function pointers

The function pointers are categorized into pointer types. However, a function pointer is never dangling in a program. This should be clarified in section r-undefined.dangling.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Reference sections on undefined dangling pointers and pointer type kinds, and compare how function pointers fit their definitions. Clarify the dangling-pointer wording so its treatment of function pointers is unambiguous; the linked sections should reflect the resolved explanation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.