Skip to content

Conversation

@kkysen
Copy link
Contributor

@kkysen kkysen commented Oct 28, 2025

A test for #1435. It was broken by #1266 (specifically, 7eaa39f, which also doesn't compile). It seems we're not handling the U suffix, which requires a temporary cast to c_uint before getting coerced to int32_t/i32.

4a4c0cc is the current snapshot, while 36d829e is what it was before #1266, which still compiles.

@kkysen kkysen force-pushed the kkysen/out-of-range-int branch from 36d829e to d1799d6 Compare October 28, 2025 05:49
@fw-immunant
Copy link
Contributor

Ah, my bad re: 7eaa39f not compiling--it depends on 67e6eeb but got reordered prior to it during cleanup of that PR.

I believe the problem here is referenced by the doc comment for literal_kind_matches_ty:

Return whether the literal can be directly translated as this type. This does not check that the literal fits into the type's range of values (as doing so is in general dependent on the target platform), just that it is the appropriate kind for the type.

For fixed-size types like int32_t, we can relatively easily check the literal against their fixed bounds, but for types like libc::c_int we need to be able to determine the bounds for int on the target platform.

Copy link
Contributor Author

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for types like libc::c_int we need to be able to determine the bounds for int on the target platform.

See #1442 now, but I chose to use the narrowest bound for platform-dependent types like int so that the resulting code works on all platforms.

@kkysen
Copy link
Contributor Author

kkysen commented Nov 1, 2025

@kkysen kkysen closed this Nov 1, 2025
@kkysen kkysen deleted the kkysen/out-of-range-int branch November 1, 2025 08:13
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

Successfully merging this pull request may close these issues.

3 participants