Skip to content

pointers to "comptime mutable" data should be const pointers outside the comptime scope #1487

Open
@tgschultz

Description

@tgschultz

The following crashes on Windows.

const std = @import("std");

var allocator = &std.heap.DirectAllocator.init().allocator;

test "" {
    var memory = allocator.alloc(u8, 1);
}

replacing the allocator line with:

var direct_allocator = std.heap.DirectAllocator.init();
var allocator = &direct_allocator.allocator;

succeeds.

I'm guessing this is because DirectAllocator needs to maintain state on Windows because of the heap handle, and something about the failing test case's construction causes the outer struct to become invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions