Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2f6e9966
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2f6e9966
编写于
7月 04, 2022
作者:
R
Ralf Jung
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
always check overflow in CheckedBinOp in CTFE
上级
6f01ff61
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
3 deletion
+13
-3
compiler/rustc_const_eval/src/interpret/machine.rs
compiler/rustc_const_eval/src/interpret/machine.rs
+8
-0
compiler/rustc_const_eval/src/interpret/operator.rs
compiler/rustc_const_eval/src/interpret/operator.rs
+2
-1
compiler/rustc_middle/src/mir/syntax.rs
compiler/rustc_middle/src/mir/syntax.rs
+3
-2
未找到文件。
compiler/rustc_const_eval/src/interpret/machine.rs
浏览文件 @
2f6e9966
...
...
@@ -144,6 +144,9 @@ fn enforce_abi(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
true
}
/// Whether CheckedBinOp MIR statements should actually check for overflow.
fn
check_binop_checks_overflow
(
_
ecx
:
&
InterpCx
<
'mir
,
'tcx
,
Self
>
)
->
bool
;
/// Entry point for obtaining the MIR of anything that should get evaluated.
/// So not just functions and shims, but also const/static initializers, anonymous
/// constants, ...
...
...
@@ -468,6 +471,11 @@ fn enforce_number_no_provenance(_ecx: &InterpCx<$mir, $tcx, Self>) -> bool {
true
}
#[inline(always)]
fn
check_binop_checks_overflow
(
_
ecx
:
&
InterpCx
<
$
mir
,
$
tcx
,
Self
>
)
->
bool
{
true
}
#[inline(always)]
fn
call_extra_fn
(
_
ecx
:
&
mut
InterpCx
<
$
mir
,
$
tcx
,
Self
>
,
...
...
compiler/rustc_const_eval/src/interpret/operator.rs
浏览文件 @
2f6e9966
...
...
@@ -32,7 +32,8 @@ pub fn binop_with_overflow(
);
// As per https://github.com/rust-lang/rust/pull/98738, we always return `false` in the 2nd
// component when overflow checking is disabled.
let
overflowed
=
overflowed
&&
(
force_overflow_checks
||
self
.tcx.sess
.overflow_checks
());
let
overflowed
=
overflowed
&&
(
force_overflow_checks
||
M
::
check_binop_checks_overflow
(
self
));
// Write the result to `dest`.
if
let
Abi
::
ScalarPair
(
..
)
=
dest
.layout.abi
{
// We can use the optimized path and avoid `place_field` (which might do
...
...
compiler/rustc_middle/src/mir/syntax.rs
浏览文件 @
2f6e9966
...
...
@@ -993,8 +993,9 @@ pub enum Rvalue<'tcx> {
/// Same as `BinaryOp`, but yields `(T, bool)` with a `bool` indicating an error condition.
///
/// When overflow checking is disabled, the error condition is false. Otherwise, the error
/// condition is determined as described below.
/// When overflow checking is disabled and we are generating run-time code, the error condition
/// is false. Otherwise, and always during CTFE, the error condition is determined as described
/// below.
///
/// For addition, subtraction, and multiplication on integers the error condition is set when
/// the infinite precision result would be unequal to the actual result.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录