Skip to content

Naked functions do not require unsafety #32489

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
nagisa opened this issue Mar 25, 2016 · 3 comments · Fixed by #93153
Closed

Naked functions do not require unsafety #32489

nagisa opened this issue Mar 25, 2016 · 3 comments · Fixed by #93153
Labels
A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. requires-nightly This issue requires a nightly compiler in some way. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@nagisa
Copy link
Member

nagisa commented Mar 25, 2016

RFC states that naked functions must either not contain any “safe” blocks or be unsafe themselves. Currently, code like

#![feature(asm, naked_functions)]

#[naked]
extern "win64" fn naked(x: u32) -> u32 {
    x + 1
}

is accepted.

@nagisa
Copy link
Member Author

nagisa commented Mar 25, 2016

cc #32408

@nagisa nagisa added the A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS label Jun 2, 2016
@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. labels Jul 24, 2017
@steveklabnik
Copy link
Member

Triage: still reproduces today

@jonas-schievink jonas-schievink added requires-nightly This issue requires a nightly compiler in some way. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Dec 25, 2019
@npmccallum
Copy link
Contributor

@nagisa @steveklabnik I propose we reject this bug in light of the Constrained Naked RFC. There is nothing which prevents a naked function from being safe.

tmiasko added a commit to tmiasko/rust that referenced this issue Jan 21, 2022
Transition unsupported naked functions future incompatibility lint into
an error:

* Naked functions must contain a single inline assembly block.
  Introduced as future incompatibility lint in 1.50 rust-lang#79653.
  Change into an error fixes a soundness issue described in rust-lang#32489.

* Naked functions must not use any forms of inline attribute.
  Introduced as future incompatibility lint in 1.56 rust-lang#87652.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 22, 2022
…nctions, r=Amanieu

Reject unsupported naked functions

Transition unsupported naked functions future incompatibility lint into an error:

* Naked functions must contain a single inline assembly block. Introduced as future incompatibility lint in 1.50 rust-lang#79653. Change into an error fixes a soundness issue described in rust-lang#32489.

* Naked functions must not use any forms of inline attribute. Introduced as future incompatibility lint in 1.56 rust-lang#87652.

Closes rust-lang#32490.
Closes rust-lang#32489.

r? `@Amanieu` `@npmccallum` `@joshtriplett`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 22, 2022
…nctions, r=Amanieu

Reject unsupported naked functions

Transition unsupported naked functions future incompatibility lint into an error:

* Naked functions must contain a single inline assembly block. Introduced as future incompatibility lint in 1.50 rust-lang#79653. Change into an error fixes a soundness issue described in rust-lang#32489.

* Naked functions must not use any forms of inline attribute. Introduced as future incompatibility lint in 1.56 rust-lang#87652.

Closes rust-lang#32490.
Closes rust-lang#32489.

r? ``@Amanieu`` ``@npmccallum`` ``@joshtriplett``
@bors bors closed this as completed in a8f64c0 Jan 22, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-naked Area: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzS C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. requires-nightly This issue requires a nightly compiler in some way. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants