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

Aligncast crashes the compiler #3610

Closed
DutchGhost opened this issue Nov 5, 2019 · 2 comments
Closed

Aligncast crashes the compiler #3610

DutchGhost opened this issue Nov 5, 2019 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@DutchGhost
Copy link

DutchGhost commented Nov 5, 2019

The following:

const Maybe = extern union {
    value: void,
    uninit: void,

    pub inline fn zeroed() Maybe {
        var u = Maybe{ .uninit = {} };
        var aligned_ptr = @alignCast(1, &u.value);

        return u;
    }
};

pub fn main() void {
    var maybe = Maybe.zeroed();
}

crashes the compiler:

Assertion failed at /deps/zig/src/analyze.cpp:565 in get_pointer_to_type_extra. This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped

Program received signal SIGABRT, Aborted.
__restore_sigs (set=set@entry=0x7ffffffed240) at ./arch/x86_64/syscall_arch.h:40
40      ./arch/x86_64/syscall_arch.h: No such file or directory.
(gdb) backtrace
#0  __restore_sigs (set=set@entry=0x7ffffffed240) at ./arch/x86_64/syscall_arch.h:40
#1  0x000000000d11c274 in raise (sig=sig@entry=6) at src/signal/raise.c:11
#2  0x000000000d116098 in abort () at src/exit/abort.c:13
#3  0x00000000088dad76 in std.os.abort ()
#4  0x0000000000000000 in ?? ()
(gdb)
@andrewrk andrewrk added this to the 0.6.0 milestone Nov 14, 2019
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Nov 14, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Feb 21, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Aug 13, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@nektro
Copy link
Contributor

nektro commented Oct 12, 2021

this now produces error: cannot adjust alignment of zero sized type '*void'

changing 1 to 0 produces error: alignment must be >= 1

@Vexu
Copy link
Member

Vexu commented Dec 8, 2021

Fixed by #5969.

@Vexu Vexu closed this as completed Dec 8, 2021
@Vexu Vexu removed this from the 0.11.0 milestone Dec 8, 2021
@andrewrk andrewrk added this to the 0.7.0 milestone Dec 8, 2021
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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

4 participants