Skip to content

Pointer operations must be wrapped in unsafe #19819

@ArtemkaKun

Description

@ArtemkaKun

Describe the bug

The code below shows how to mutate variable that wasn't marked as mut. Since V is considered to be a secure language, pointer operations like below must be wrapped in unsafe block so it will be clear for end programmer what is going on

Reproduction Steps

c := 0
cref := &c
(*cref)++

println(c)

Expected Behavior

Outputs warning, outputs 1

Current Behavior

No warning, outputs 1

Possible Solution

No response

Additional Information/Context

No response

V version

0.4.2

Environment details (OS name and version, etc.)

Unrelated

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.Unit: Type SystemBugs/feature requests, that are related to the V types system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions