News for hackers. Stuff that matters.
Re:An intro to Zig's integer casting for C programmers by messe on Tuesday May 11, 2021 @11:57AM (#27119700)
> Curious fact: the above code generates >40000 lines of assembly in godbolt: https://www.godbolt.org/z/fxfbb9jfn

I took a quick glance at the ASM, and it seems that the majority of that is code from the stdlib run prior to main. Compiling with -OReleaseSafe brings that down to 15,000 lines of assembly.

If you get rid of "main" and compile it as an exported function, you get far less code: https://www.godbolt.org/z/jjGP4xsfx

If you add -OReleaseSafe to the "export fn" version I shared, it's around 4 lines of code calling panic. Adding -OReleaseFast, and it's just a ret statement.

Re:An intro to Zig's integer casting for C programmers by meepmorp on Tuesday May 11, 2021 @01:37PM (#27120983)
> Compiling with -OReleaseSafe brings that down to 15,000 lines of assembly.

I tried it with -OReleaseFast to compare, and it's 500-ish lines. That's amazing.