Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Allow pointers in inline assembly const expressions #132012

Copy link
Copy link
@dingxiangfei2009

Description

@dingxiangfei2009
Issue body actions

Quoting from tests/ui/asm/const-refs-to-static.rs @ 31e102c

I tried this code:

use std::arch::{asm, global_asm};
use std::ptr::addr_of;

static FOO: u8 = 42;

#[no_mangle]
fn inline() {
    unsafe { asm!("{}", const addr_of!(FOO)) };
}

I expected to see this happen: it should compiles

Instead, this happened: *const u8 is not allowed as an operand to inline assembly.

This would be coming useful and brings us feature-parity with asm(" /* assembly */ " ::"i"(ptr)) from C, where ptr can be pointer to statics and constants.

cc @Amanieu @nbdd0121

Meta

rustc --version --verbose:

<version>
Backtrace

<backtrace>

Metadata

Metadata

Labels

A-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)A-rust-for-linuxRelevant for the Rust-for-Linux projectRelevant for the Rust-for-Linux projectC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.