Skip to content

struct with field default initialized to size of the struct gives false positive 'depends on itself' error #12029

@andrewrk

Description

@andrewrk

Zig Version: 0.10.0-dev.2857+4e002dde6

const S = extern struct {
    size: u8 = @sizeOf(S),
    blah: u16,
};

test "struct default value initialize to size of itself" {
    var s: S = undefined;
    _ = s;
}
[nix-shell:~/dev/zig/build-release]$ stage2/bin/zig test test3.zig 
test3.zig:8:5: error: struct 'test3.S' depends on itself
    size: u8 = @sizeOf(S),
    ^

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions