Another UB found using rustlantis

未关闭
#691 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust
领域
compilers

调研方向

首先,使用 GCC 在 debug 和 release 模式下编译并运行所提供的 Rust 复现程序,然后跟踪报告中提到的 boolean 到 integer 的 cast。当该 cast 始终生成预期的 boolean 值,而不是在不同构建之间产生差异时,问题即得到解决。

由索引模型根据 Issue 内容生成。

描述

bug

This program has a different result under GCC debug and GCC release.

2 1 //debug
2 -1 // release
fn dump_var(var2: usize, val2: usize, var3: usize) {
    println!("val2:{val2}")
}
#[inline(never)]
fn dump_var2(var2: usize, val2: usize, var3: usize) {
    println!("val2:{val2}")
}
fn fn6(arg: bool, arg2: usize) -> bool {
    dump_var(0, arg2, 0);
    dump_var2(0, !arg as usize, 0);
    true
}
fn main() {
    let mut _1 = false;
    let mut _3 = 2;
    let mut _4 = (&1, 1);
    loop {
        if _4.1 == 0 {
            if _4.1 == 1 {
                _1 = true;
            } else {
                _1 = false;
            }
        } else if fn6(_1, _3) {
            loop {
                _3 = _4.1;
                let mut _6 = 0;
                _6 = 0;
                let tmp2 = _6;
                if tmp2 == 1 {
                    _4.0 = &_4.1
                } else if tmp2 == 0 {
                    return;
                } else {
                    break;
                }
            }
        }
    }
}

It looks like the cast of val as i128 is nonsensical. Since val is a boolean value, one would expect it to be either 1 or 0, and not -1.

主要语言
Rust
星标
1.2k
派生
106
平均合并
11 小时 14 分钟
30 天内合并 PR
25

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rust-lang/rustc_codegen_gcc 的其他 Issue

查看 rust-lang/rustc_codegen_gcc 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。