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

stage2: miscompilation w/ pointers to zero sized types #13363

Closed
ethernetsellout opened this issue Oct 30, 2022 · 0 comments
Closed

stage2: miscompilation w/ pointers to zero sized types #13363

ethernetsellout opened this issue Oct 30, 2022 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. miscompilation The compiler reports success but produces semantically incorrect code.
Milestone

Comments

@ethernetsellout
Copy link

Zig Version

0.10.0-dev.4711+2b25d3c33

Steps to Reproduce and Observed Behavior

run this code:

const std = @import("std");

const A = struct {
    b: void = {},
    u: u8
};

pub fn main() !void {
    var a = A { .u = 0 };
    const a_ptr = @fieldParentPtr(A, "b", &a.b);
    try std.testing.expectEqual(&a, a_ptr);
}

output:
expected ab.A@5a405ffca8, found ab.A@5a405ffca9

Expected Behavior

per #6706 I would expect a_ptr to point to a.

@ethernetsellout ethernetsellout added the bug Observed behavior contradicts documented or intended behavior label Oct 30, 2022
@andrewrk andrewrk added frontend Tokenization, parsing, AstGen, Sema, and Liveness. miscompilation The compiler reports success but produces semantically incorrect code. labels Oct 31, 2022
@andrewrk andrewrk added this to the 0.10.1 milestone Oct 31, 2022
Vexu added a commit to Vexu/zig that referenced this issue Nov 8, 2022
If the field comes before any non-zero-bit field then the index of
the next field should be returned.

Closes ziglang#13363
Vexu added a commit to Vexu/zig that referenced this issue Nov 9, 2022
If the field comes before any non-zero-bit field then the index of
the next field should be returned.

Closes ziglang#13363
Vexu added a commit to Vexu/zig that referenced this issue Nov 9, 2022
If the field comes before any non-zero-bit field then the index of
the next field should be returned.

Closes ziglang#13363
@Vexu Vexu closed this as completed in d2cc551 Nov 13, 2022
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. miscompilation The compiler reports success but produces semantically incorrect code.
Projects
None yet
Development

No branches or pull requests

2 participants