Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler segfault when creating an opaque variable as undefined #16617

Closed
xdBronch opened this issue Jul 30, 2023 · 1 comment
Closed

compiler segfault when creating an opaque variable as undefined #16617

xdBronch opened this issue Jul 30, 2023 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@xdBronch
Copy link
Contributor

Zig Version

0.11.0-dev.4308 417b92f08

Steps to Reproduce and Observed Behavior

// opaque.zig
test {
    const ot = opaque {};
    const ov: ot = undefined;
    _ = ov;
}

zig test opaque.zig

output
segmentation fault (core dumped) zig test c.zig in release build of compiler
https://gist.github.com/xdBronch/40a5fe215c1b63318998260cb6085d95 contents of this gist with a debug build

Expected Behavior

successful build or compile error, im not entirely sure the semantics of opaque types so i dont know which is expected.

@xdBronch xdBronch added the bug Observed behavior contradicts documented or intended behavior label Jul 30, 2023
@andrewrk andrewrk added this to the 0.11.1 milestone Jul 31, 2023
@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Jan 11, 2024
@Vexu Vexu modified the milestones: 0.11.1, 0.13.0 Jan 11, 2024
@fmaggi
Copy link
Contributor

fmaggi commented Jul 8, 2024

if ov is var instead of const I get a correct error I think

test {
    const ot = opaque {};
    var ov: ot = undefined;
    _ = &ov;
}
src/main.zig:67:13: error: non-extern variable with opaque type 'main.test_0.ot'
    var ov: ot = undefined;
            ^~
src/main.zig:66:16: note: opaque declared here
    const ot = opaque {};
               ^~~~~~~~~

Could it be a comptime bug?

That error messages is used in Sema.validateVarType which only runs on runtime variables. I guess because ov is const its never getting checked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

4 participants