DEREF_NULLPTR in rustc_lint::builtin - Rust
Description: The `deref_nullptr` lint detects when a null pointer is dereferenced, which causes undefined behavior.

Skip to main content

## DEREF_NULLPTR

# Static DEREF_NULLPTR

Source

    pub static DEREF_NULLPTR: &Lint

Expand description

The `deref_nullptr` lint detects when a null pointer is dereferenced, which causes undefined behavior.

#### §Example

ⓘ

    use std::ptr;
    unsafe {
        let x = &*ptr::null::<i32>();
        let x = ptr::addr_of!(*ptr::null::<i32>());
        let x = *(0 as *const i32);
    }

{{produces}}

#### §Explanation

Dereferencing a null pointer causes undefined behavior if it is accessed (loaded from or stored to).