Skip to content

llvm lint: "Unusual: Address one pointer dereference" on unsafe code #60320

Closed
@matthiaskrgr

Description

@matthiaskrgr
rustc 1.36.0-nightly (3991285f5 2019-04-25)
binary: rustc
commit-hash: 3991285f55a4b7cd92b7ffcdc396a3023076f5cb
commit-date: 2019-04-25
host: x86_64-unknown-linux-gnu
release: 1.36.0-nightly
LLVM version: 8.0
rustc src/test/run-pass/signal-exit-status.rs -C passes=lint -C opt-level=3
Unusual: Address one pointer dereference
  store i64 0, i64* inttoptr (i64 1 to i64*), align 8

code:

// ignore-cloudabi no processes
// ignore-emscripten no processes
// ignore-windows

use std::env;
use std::process::Command;

pub fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() >= 2 && args[1] == "signal" {
        // Raise a segfault.
        unsafe { *(1 as *mut isize) = 0; }
    } else {
        let status = Command::new(&args[0]).arg("signal").status().unwrap();
        assert!(status.code().is_none());
    }
}

Is this expected given the snippet contains unsafe code?

cc #7463

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationT-compilerRelevant to the compiler 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