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

memset on global variable gives "out of bounds pointer access" #718

Closed
andrewrk opened this Issue Jan 24, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@andrewrk
Copy link
Member

andrewrk commented Jan 24, 2018

const mem = @import("std").mem;

const Keys = struct {
    up: bool,
    down: bool,
    left: bool,
    right: bool,
};

var keys: Keys = undefined;

test "zero keys with @memset" {
    @memset(@ptrCast(&u8, &keys), 0, @sizeOf(@typeOf(keys)));
}
/home/andy/tmp/test.zig:13:38: error: out of bounds pointer access
    @memset(@ptrCast(&u8, &keys), 0, @sizeOf(@typeOf(keys)));
                                     ^

@andrewrk andrewrk added the bug label Jan 24, 2018

@andrewrk andrewrk added this to the 0.3.0 milestone Jan 24, 2018

@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Feb 28, 2018

@andrewrk andrewrk closed this in 7571db0 Feb 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.