Skip to content

@floatToInt compiler crash on c_longdouble #1188

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

Closed
tiehuis opened this issue Jul 3, 2018 · 6 comments
Closed

@floatToInt compiler crash on c_longdouble #1188

tiehuis opened this issue Jul 3, 2018 · 6 comments
Assignees
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.

Comments

@tiehuis
Copy link
Member

tiehuis commented Jul 3, 2018

Minor, since c_longdouble isn't commonly used.

pub fn main() void {
    const a: c_longdouble = 1.4;
    const b = @floatToInt(u32, a);
}
unreachable: /home/me/src/zig/src/ir.cpp:eval_const_expr_implicit_cast:8961
#0  0x00007ffff630886b in raise () from /usr/lib/libc.so.6
#1  0x00007ffff62f340e in abort () from /usr/lib/libc.so.6
#2  0x0000555555e04e5c in zig_panic(char const*, ...) ()
#3  0x0000555555f1601c in ir_resolve_cast(IrAnalyze*, IrInstruction*, IrInstruction*, TypeTableEntry*, CastOp, bool) ()
#4  0x0000555555f24c2d in ir_analyze_instruction_decl_var(IrAnalyze*, IrInstructionDeclVar*) ()
#5  0x0000555555f3b6b1 in ir_analyze_instruction_nocast(IrAnalyze*, IrInstruction*) ()
#6  0x0000555555f3d2b1 in ir_analyze(CodeGen*, IrExecutable*, IrExecutable*, TypeTableEntry*, AstNode*) ()
#7  0x0000555555edd1f5 in analyze_fn_ir(CodeGen*, FnTableEntry*, AstNode*) ()
#8  0x0000555555eddf00 in semantic_analyze(CodeGen*) ()
#9  0x0000555555f031f8 in codegen_build(CodeGen*) ()
#10 0x0000555555e4855d in main ()
@tiehuis tiehuis added the bug Observed behavior contradicts documented or intended behavior label Jul 3, 2018
@andrewrk andrewrk added this to the 0.3.0 milestone Jul 3, 2018
@andrewrk
Copy link
Member

andrewrk commented Jul 3, 2018

I think there are a lot of places that c_longdouble is probably broken:

[nix-shell:~/downloads/zig/build]$ grep -RIn 'case 16' ../src
../src/ir.cpp:7253:            case 16:
../src/ir.cpp:7281:            case 16:
../src/ir.cpp:7319:            case 16:
../src/ir.cpp:7366:            case 16:
../src/ir.cpp:7391:            case 16:
../src/ir.cpp:7416:            case 16:
../src/ir.cpp:7445:            case 16:
../src/ir.cpp:7474:            case 16:
../src/ir.cpp:7507:            case 16:
../src/ir.cpp:7533:            case 16:
../src/ir.cpp:7578:            case 16:
../src/ir.cpp:7630:            case 16:
../src/ir.cpp:7657:            case 16:
../src/ir.cpp:7684:            case 16:
../src/ir.cpp:7711:            case 16:
../src/ir.cpp:7738:            case 16:
../src/ir.cpp:7767:            case 16:
../src/ir.cpp:7796:            case 16:
../src/ir.cpp:7841:            case 16:
../src/ir.cpp:7867:            case 16:
../src/ir.cpp:7895:            case 16:
../src/ir.cpp:7918:            case 16:
../src/ir.cpp:8948:                    case 16:
../src/ir.cpp:8981:                    case 16:
../src/ir.cpp:20336:                case 16:
../src/codegen.cpp:5232:                case 16:
../src/analyze.cpp:1405:                case 16:
../src/analyze.cpp:4672:                case 16:
../src/analyze.cpp:5139:            case 16:
../src/analyze.cpp:5455:                case 16:
../src/analyze.cpp:5644:                case 16:

@bnoordhuis
Copy link
Contributor

Is anyone working on this? If not, I can probably take this on sometime this week.

@andrewrk
Copy link
Member

andrewrk commented Jul 3, 2018

I'm not working on this yet. If I do I'll assign to myself.

@tiehuis
Copy link
Member Author

tiehuis commented Feb 15, 2019

I had a look at this a long while ago but I'll pick it up again soon.

@andrewrk
Copy link
Member

@tiehuis made some progress on this in #1985 but it's not finished. This PR would be a good starting point for anyone looking to solve this issue.

@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Aug 27, 2019
@andrewrk andrewrk added the stage1 The process of building from source via WebAssembly and the C backend. label Dec 9, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Dec 9, 2019
@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
@Vexu
Copy link
Member

Vexu commented Dec 7, 2022

Works in self-hosted.

test "@intToFloat(f80)" {

@Vexu Vexu closed this as completed Dec 7, 2022
@Vexu Vexu removed this from the 0.12.0 milestone Dec 7, 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 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.

4 participants