transpile: Cast overflow builtin operands to the output type#1863
Open
thedataking wants to merge 1 commit into
Open
transpile: Cast overflow builtin operands to the output type#1863thedataking wants to merge 1 commit into
thedataking wants to merge 1 commit into
Conversation
The overflow builtins lower to `overflowing_*`, which requires both operands to share the receiver's type. Surfaced by transpiling libgit2.
Contributor
|
@thedataking I don't think there is any overlap between the two PRs, since this one deals with the parameter types and not the actual result type of the function. |
ahomescu
reviewed
Jun 19, 2026
| let [a, b, c]: [_; 3] = args | ||
| .try_into() | ||
| .map_err(|_| "`convert_overflow_arith` must have exactly 3 arguments")?; | ||
| let a = mk().cast_expr(a, result_ty.clone()); |
Contributor
There was a problem hiding this comment.
gcc is being very loose with the type system here:
These built-in functions promote the first two operands into infinite precision signed type and perform addition on those promoted operands. The result is then cast to the type the third pointer argument points to and stored there. [...] The first built-in function allows arbitrary integral types for operands and the result type must be pointer to some integral type other than enumerated or boolean type
I'm not sure casting to the result type is correct here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Possibly superseded by the broader builtin type-handling rework in #1860 / #1707. Tagging @Rua for coordination.