Skip to content

RUNTIME ERROR: invalid memory access #22445

@ufm

Description

@ufm

Describe the bug

RUNTIME ERROR: invalid memory access

Reproduction Steps

fn main() {
    m := { "1":"1", "2":"2" }
    if b := m["1"] {
        defer { println(b)}
        println("ok")
    }
}

Result:

ufm@ufmpc:~/src/vtest$ ./vt
ok

ufm@ufmpc:~/src/vtest$ ./vt
ok

ufm@ufmpc:~/src/vtest$ ./vt
ok

ufm@ufmpc:~/src/vtest$ ./vt
ok

ufm@ufmpc:~/src/vtest$ ./vt
ok
0x774c4afa07cd: at ???: RUNTIME ERROR: invalid memory access
0x01f69500: by ???
Segmentation fault (core dumped)

Expected Behavior

Get the value of "b" or get a compiler error saying that this is not allowed.

Current Behavior

0x7178a25a07cd: at ???: RUNTIME ERROR: invalid memory access
0x02892500: by ???
Segmentation fault (core dumped)

Possible Solution

No response

Additional Information/Context

No response

V version

0.4.8 e1b842a

Environment details (OS name and version, etc.)

Linux

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.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions