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

Unreachable at analyze.cpp:9529 in resolve_llvm_types #7843

Open
ghost opened this issue Jan 20, 2021 · 5 comments · May be fixed by #16047
Open

Unreachable at analyze.cpp:9529 in resolve_llvm_types #7843

ghost opened this issue Jan 20, 2021 · 5 comments · May be fixed by #16047
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@ghost
Copy link

ghost commented Jan 20, 2021

Here is the most minimal code that reproduces the bug:

pub fn main() void {
    asm volatile(""
        :
        : [_] "{al}" (u8)
    );
}
sapphire@Raphi-Spoerri[1]₁ ~> zig build-exe main.zig && zig fmt main.zig && ./main                                                  12:54:16
Unreachable at /home/andy/dev/bootstrap-zig/zig/src/stage1/analyze.cpp:9529 in resolve_llvm_types. This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped
fish: “zig build-exe main.zig” terminated by signal SIGABRT (Abort)
sapphire@Raphi-Spoerri[SIGABRT]₁₃₄ ~> zig version
0.7.0
sapphire@Raphi-Spoerri[0]₀ ~>                                                                                                       12:54:22
@LemonBoy
Copy link
Contributor

Your code makes no sense, you're trying to pass a type value u8 as an input.
The compiler should validate the arguments to asm blocks, that's a well-known bug nobody wants to fix in stage1.

@g-w1
Copy link
Contributor

g-w1 commented Jan 20, 2021

You are still using u8. The compiler is probably pointing to the start of the assembly expression. u8 is a type, and assembly can't operate with types.

What are you trying to do?

@ghost ghost changed the title Bug: Inline assembly expressions are broken Unreachable iat analyze.cpp:9529 in resolve_llvm_types Jan 20, 2021
@ghost ghost changed the title Unreachable iat analyze.cpp:9529 in resolve_llvm_types Unreachable at analyze.cpp:9529 in resolve_llvm_types Jan 20, 2021
@ghost
Copy link
Author

ghost commented Jan 21, 2021

You are still using u8. The compiler is probably pointing to the start of the assembly expression. u8 is a type, and assembly can't operate with types.

What are you trying to do?

Goofing off, for all I know.
My point is, even a compiler segfault is more helpful than the compile error use of undeclared identifier 'u8' when a runtime lvalue is required.

@ghost
Copy link
Author

ghost commented Jan 21, 2021

Your code makes no sense, you're trying to pass a type value u8 as an input.
The compiler should validate the arguments to asm blocks, that's a well-known bug nobody wants to fix in stage1.

Ok. Should the title be generalized to "Compiler does not validate arguments passed to asm"?

@g-w1
Copy link
Contributor

g-w1 commented Jan 21, 2021

I think it is fine for now. u8 is not valid in assembly and the compiler told you that, just in a confusing way to you.

@jayschwa jayschwa added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Jan 24, 2021
@Vexu Vexu added this to the 0.9.0 milestone Jan 26, 2021
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
wooster0 added a commit to wooster0/zig that referenced this issue Jun 15, 2023
@wooster0 wooster0 linked a pull request Jun 15, 2023 that will close this issue
wooster0 added a commit to wooster0/zig that referenced this issue Jun 27, 2023
wooster0 added a commit to wooster0/zig that referenced this issue Jul 11, 2023
wooster0 added a commit to wooster0/zig that referenced this issue Jul 11, 2023
wooster0 added a commit to wooster0/zig that referenced this issue Jul 11, 2023
wooster0 added a commit to wooster0/zig that referenced this issue Jul 11, 2023
wooster0 added a commit to wooster0/zig that referenced this issue Jul 11, 2023
andrewrk pushed a commit to wooster0/zig that referenced this issue Sep 17, 2023
wooster0 added a commit to wooster0/zig that referenced this issue Mar 14, 2024
andrewrk pushed a commit to wooster0/zig that referenced this issue May 9, 2024
wooster0 added a commit to wooster0/zig that referenced this issue May 11, 2024
wooster0 added a commit to wooster0/zig that referenced this issue May 13, 2024
wooster0 added a commit to wooster0/zig that referenced this issue Aug 24, 2024
wooster0 added a commit to wooster0/zig that referenced this issue Aug 25, 2024
wooster0 added a commit to wooster0/zig that referenced this issue Sep 12, 2024
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

Successfully merging a pull request may close this issue.

5 participants