rust-lang / rust-lang/rustc_codegen_gcc

Possible bug in 128-bit integers implementation (gcc_checked_binop)

Open
#588 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
1.2k
Forks
105
Avg merge
8h 20m
Merged PRs (30d)
14

Description

It seems there's a mixup between the overflow flag and the result of the operation from what we could see here.

The code that might be wrong is here.

For instance __mulosi4 has the following signature:

si_int __mulosi4(si_int a, si_int b, int *overflow);

while __builtin_mul_overflow has:

bool __builtin_mul_overflow (type1 a, type2 b, type3 *res)

Yet, they seem to be called the same way (mixing up overflow with the return value of res with the other return value).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read src/int.rs around lines 278-364, then compare the referenced compiler-rt __mulosi4 and GCC __builtin_mul_overflow signatures and calling conventions. Trace how the overflow flag and operation result are passed through gcc_checked_binop, and confirm the implementation distinguishes the two APIs correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.