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

Compiler crash when using special integers sizes #7322

Closed
Inky-developer opened this issue Dec 6, 2020 · 2 comments
Closed

Compiler crash when using special integers sizes #7322

Inky-developer opened this issue Dec 6, 2020 · 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

@Inky-developer
Copy link

After reading the first lines of the zig documentation, I found out that zig supports special integers sizes like i7 or i65535. However, the following program:

const std = @import("std");
const print = std.debug.print;

pub fn main() void {
    var strange_int: i129 = 14;
    print("{}\n", .{strange_int});
}

fails with:

>>> zig run hello.zig 
Assertion failed at /home/andy/dev/bootstrap-zig/zig/src/stage1/analyze.cpp:9586 in get_llvm_type. This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped

Interestingely, when using an integer type of i185 or higher, the error changes to:

LLVM ERROR: Unsupported library call operation!

integers below i129 seem to work fine for me.

I am using windows with zig version 0.7.0.

@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 Dec 8, 2020
@andrewrk andrewrk added this to the 0.9.0 milestone Dec 8, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@mikdusan
Copy link
Member

mikdusan commented Jan 7, 2023

with latest compiler:

  • compiler no longer asserts
  • appears this was fixed after 0.10.0
  • it may have been partially fixed at 0.10.0 but missing symbol __umodei4
repro.zig
const std = @import("std");
const print = std.debug.print;

pub fn main() void {
    var num1: i129 = 14;
    print("0x{x}\n", .{num1});

    var num2: i185 = 15;
    print("0x{x}\n", .{num2});

    var num3: i185 = std.math.maxInt(i185);
    print("0x{x}\n", .{num3});

    var num4: i256 = @as(i256, num1) + @as(i256, num2) + @as(i256, num3);
    print("0x{x}\n", .{num4});
}
$ uname -a
Linux archlinux 6.1.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 31 Dec 2022 17:40:35 +0000 x86_64 GNU/Linux

$ zig version
0.11.0-dev.1247+87b223428

$ zig run repro.zig
0xe
0xf
0xffffffffffffffffffffffffffffffffffffffffffffff
0x1000000000000000000000000000000000000000000001c

@mikdusan mikdusan closed this as completed Jan 7, 2023
@nektro
Copy link
Contributor

nektro commented Jan 7, 2023

this was a duplicate of #1485 and fixed with the switch to llvm 15

@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Jan 8, 2023
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