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

Integer literal promotion rules should emulate chosen compiler #690

Open
ehaas opened this issue Apr 22, 2024 · 0 comments
Open

Integer literal promotion rules should emulate chosen compiler #690

ehaas opened this issue Apr 22, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ehaas
Copy link
Collaborator

ehaas commented Apr 22, 2024

GCC and clang behave differently with regard to unsuffixed integer literals; see comment here ziglang/zig#19701 (comment) Note: MSVC follows the clang behavior of promoting to unsigned long long

The current behavior is implemented here:

arocc/src/aro/Parser.zig

Lines 8395 to 8402 in f60a2de

for (specs) |spec| {
res.ty = Type{ .specifier = spec };
if (res.ty.compareIntegerRanks(suffix_ty, p.comp).compare(.lt)) continue;
const max_int = res.ty.maxInt(p.comp);
if (val <= max_int) break;
} else {
res.ty = .{ .specifier = .ulong_long };
}

@ehaas ehaas added enhancement New feature or request good first issue Good for newcomers labels Apr 22, 2024
@ehaas ehaas changed the title Integer literal promotion rules should emulated chosen compiler Integer literal promotion rules should emulate chosen compiler Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant