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 nullderef(??) #1421

Closed
DutchGhost opened this issue Aug 26, 2018 · 3 comments
Closed

Compiler nullderef(??) #1421

DutchGhost opened this issue Aug 26, 2018 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@DutchGhost
Copy link

compiling the following code with build https://ci.appveyor.com/project/andrewrk/zig-d3l86/build/0.2.0+68e2794e, crashes the compiler.

const start = struct {
    fn crash() bug() { return bug; }
};

fn bug() void {
    _ = @typeInfo(start).Struct;
}

test "example" {
    var boom = start.crash();
}

pub fn main() void {
    var boom = start.crash();
}
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Aug 26, 2018
@andrewrk andrewrk added this to the 0.3.0 milestone Aug 26, 2018
@andrewrk
Copy link
Member

Thanks for the small test case!

@DutchGhost
Copy link
Author

DutchGhost commented Aug 26, 2018

An even smaller test case:

const bug = struct {
    fn crash() @import("builtin").TypeInfo {
        return @typeInfo(bug);
    }
};

test "example" {
    const boom = bug.crash();
}

pub fn main() void {
    const boom = bug.crash();
}

kristate added a commit to kristate/zig that referenced this issue Aug 27, 2018
…o protect against dereferencing null pointers;
kristate added a commit to kristate/zig that referenced this issue Aug 27, 2018
…on definition';

Co-Authored-By: Dodo <dutchghost@users.noreply.github.com>
andrewrk added a commit that referenced this issue Aug 27, 2018
This solves the smaller test case of #1421 but the
other test case is still an assertion failure.
@andrewrk
Copy link
Member

fixed in 009e90f

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
Projects
None yet
Development

No branches or pull requests

2 participants