Skip to content

transpile: Cast overflow builtin operands to the output type#1863

Open
thedataking wants to merge 1 commit into
perl/zero-init-importsfrom
perl/overflow-builtin-types
Open

transpile: Cast overflow builtin operands to the output type#1863
thedataking wants to merge 1 commit into
perl/zero-init-importsfrom
perl/overflow-builtin-types

Conversation

@thedataking

Copy link
Copy Markdown
Contributor

Possibly superseded by the broader builtin type-handling rework in #1860 / #1707. Tagging @Rua for coordination.

The overflow builtins lower to `overflowing_*`, which requires both operands to
share the receiver's type. Surfaced by transpiling libgit2.
@thedataking thedataking requested a review from ahomescu June 18, 2026 08:43
@Rua

Rua commented Jun 18, 2026

Copy link
Copy Markdown
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.

@thedataking thedataking changed the base branch from master to perl/zero-init-imports June 18, 2026 10:27
@thedataking thedataking added the bug Something isn't working label Jun 18, 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());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants