Skip to content

type system allows setting a non-optional pointer to null via only implicit casts #1102

@andrewrk

Description

@andrewrk

after 6edd811 this is possible:

test "oaeu" {
    var x: i32 = 1234;
    var p: *i32 = &x;
    var pp: *?*i32 = &p;
    pp.* = null;
    var y = p.*;
}

it segfaults using only implicit casts, which shouldn't be possible.

runtime-assignable casting (e.g. const, volatile, and equivalent) for optional pointers should be disallowed for mutable pointer parent types. Then var pp: *?*i32 = &p; would be a compile error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions