Skip to content

Regression in Zig/C comparison #431

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

Open
vegerot opened this issue Dec 24, 2024 · 2 comments
Open

Regression in Zig/C comparison #431

vegerot opened this issue Dec 24, 2024 · 2 comments

Comments

@vegerot
Copy link

vegerot commented Dec 24, 2024

The website mentions this comparison between C and Zig.

In more recent versions, while Zig still uses faster instructions, it actually uses one more instruction which makes the comparison look less cool.

Of course it's just doing some stack management which is way faster than an imul, but just thought it was worth pointing out :)

https://godbolt.org/z/qWGvEo9o6

@alexrp
Copy link
Member

alexrp commented Apr 19, 2025

What page is this on?

@vegerot
Copy link
Author

vegerot commented May 12, 2025

This used to be on the overview, but looks like it was moved to old

- Carefully chosen undefined behavior. For example, in Zig both signed and unsigned integers have undefined behavior on overflow, contrasted to only signed integers in C. This [facilitates optimizations that are not available in C](https://godbolt.org/z/n_nLEU).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants