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

Comments

Projects
None yet
2 participants
@DutchGhost

DutchGhost commented Aug 26, 2018

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 label Aug 26, 2018

@andrewrk andrewrk added this to the 0.3.0 milestone Aug 26, 2018

@andrewrk

This comment has been minimized.

Member

andrewrk commented Aug 26, 2018

Thanks for the small test case!

@DutchGhost

This comment has been minimized.

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

ziglang#1421: src/ir.cpp: check return value of `const_ptr_pointee` t…
…o protect against dereferencing null pointers;

kristate added a commit to kristate/zig that referenced this issue Aug 27, 2018

ziglang#1421: src/ir.cpp: test case 'self referencing self via functi…
…on definition';

Co-Authored-By: Dodo <dutchghost@users.noreply.github.com>

andrewrk added a commit that referenced this issue Aug 27, 2018

fix false negative determining if function is generic
This solves the smaller test case of #1421 but the
other test case is still an assertion failure.
@andrewrk

This comment has been minimized.

Member

andrewrk commented Aug 27, 2018

fixed in 009e90f

@andrewrk andrewrk closed this Aug 27, 2018

andrewrk added a commit that referenced this issue Aug 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment