Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
46956f76
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
46956f76
编写于
7月 03, 2022
作者:
R
Ralf Jung
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adjust dangling-int-ptr error message
上级
4045ce64
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
60 addition
and
47 deletion
+60
-47
compiler/rustc_const_eval/src/interpret/machine.rs
compiler/rustc_const_eval/src/interpret/machine.rs
+2
-2
compiler/rustc_const_eval/src/interpret/place.rs
compiler/rustc_const_eval/src/interpret/place.rs
+1
-1
compiler/rustc_middle/src/mir/interpret/error.rs
compiler/rustc_middle/src/mir/interpret/error.rs
+8
-10
compiler/rustc_middle/src/mir/interpret/pointer.rs
compiler/rustc_middle/src/mir/interpret/pointer.rs
+17
-2
src/test/ui/const-ptr/forbidden_slices.32bit.stderr
src/test/ui/const-ptr/forbidden_slices.32bit.stderr
+5
-5
src/test/ui/const-ptr/forbidden_slices.64bit.stderr
src/test/ui/const-ptr/forbidden_slices.64bit.stderr
+5
-5
src/test/ui/consts/const-deref-ptr.stderr
src/test/ui/consts/const-deref-ptr.stderr
+1
-1
src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs
src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs
+2
-2
src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr
src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr
+2
-2
src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr
src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr
+1
-1
src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr
src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr
+1
-1
src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs
...i/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs
+1
-1
src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr
...nsts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr
+1
-1
src/test/ui/consts/offset_from_ub.rs
src/test/ui/consts/offset_from_ub.rs
+2
-2
src/test/ui/consts/offset_from_ub.stderr
src/test/ui/consts/offset_from_ub.stderr
+2
-2
src/test/ui/consts/offset_ub.stderr
src/test/ui/consts/offset_ub.stderr
+7
-7
src/test/ui/consts/ptr_comparisons.stderr
src/test/ui/consts/ptr_comparisons.stderr
+1
-1
src/test/ui/error-codes/E0396-fixed.stderr
src/test/ui/error-codes/E0396-fixed.stderr
+1
-1
未找到文件。
compiler/rustc_const_eval/src/interpret/machine.rs
浏览文件 @
46956f76
...
...
@@ -513,7 +513,7 @@ fn ptr_from_addr_transmute(
_
ecx
:
&
InterpCx
<
$
mir
,
$
tcx
,
Self
>
,
addr
:
u64
,
)
->
Pointer
<
Option
<
AllocId
>>
{
Pointer
::
new
(
None
,
Size
::
from_bytes
(
addr
)
)
Pointer
::
from_addr
(
addr
)
}
#[inline(always)]
...
...
@@ -523,7 +523,7 @@ fn ptr_from_addr_cast(
)
->
InterpResult
<
$
tcx
,
Pointer
<
Option
<
AllocId
>>>
{
// Allow these casts, but make the pointer not dereferenceable.
// (I.e., they behave like transmutation.)
Ok
(
Pointer
::
new
(
None
,
Size
::
from_bytes
(
addr
)
))
Ok
(
Pointer
::
from_addr
(
addr
))
}
#[inline(always)]
...
...
compiler/rustc_const_eval/src/interpret/place.rs
浏览文件 @
46956f76
...
...
@@ -188,7 +188,7 @@ impl<'tcx, Tag: Provenance> MPlaceTy<'tcx, Tag> {
#[inline]
pub
fn
dangling
(
layout
:
TyAndLayout
<
'tcx
>
)
->
Self
{
let
align
=
layout
.align.abi
;
let
ptr
=
Pointer
::
new
(
None
,
Size
::
from_bytes
(
align
.bytes
()
));
// no provenance, absolute address
let
ptr
=
Pointer
::
from_addr
(
align
.bytes
(
));
// no provenance, absolute address
// `Poison` this to make sure that the pointer value `ptr` is never observable by the program.
MPlaceTy
{
mplace
:
MemPlace
{
ptr
,
meta
:
MemPlaceMeta
::
Poison
},
layout
,
align
}
}
...
...
compiler/rustc_middle/src/mir/interpret/error.rs
浏览文件 @
46956f76
...
...
@@ -186,7 +186,7 @@ pub enum CheckInAllocMsg {
impl
fmt
::
Display
for
CheckInAllocMsg
{
/// When this is printed as an error the context looks like this:
/// "{msg}
0x01 is not a valid
pointer".
/// "{msg}
{pointer} is a dangling
pointer".
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
...
...
@@ -194,9 +194,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match
*
self
{
CheckInAllocMsg
::
DerefTest
=>
"dereferencing pointer failed: "
,
CheckInAllocMsg
::
MemoryAccessTest
=>
"memory access failed: "
,
CheckInAllocMsg
::
PointerArithmeticTest
=>
"
pointer arithmetic failed
: "
,
CheckInAllocMsg
::
PointerArithmeticTest
=>
"
out-of-bounds pointer arithmetic
: "
,
CheckInAllocMsg
::
OffsetFromTest
=>
"out-of-bounds offset_from: "
,
CheckInAllocMsg
::
InboundsTest
=>
""
,
CheckInAllocMsg
::
InboundsTest
=>
"
out-of-bounds pointer use:
"
,
}
)
}
...
...
@@ -350,14 +350,12 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ptr_size
=
ptr_size
.bytes
(),
ptr_size_p
=
pluralize!
(
ptr_size
.bytes
()),
),
DanglingIntPointer
(
0
,
CheckInAllocMsg
::
InboundsTest
)
=>
{
write!
(
f
,
"null pointer is not a valid pointer for this operation"
)
}
DanglingIntPointer
(
0
,
msg
)
=>
{
write!
(
f
,
"{msg}null pointer is not a valid pointer"
)
}
DanglingIntPointer
(
i
,
msg
)
=>
{
write!
(
f
,
"{msg}{i:#x} is not a valid pointer"
)
write!
(
f
,
"{msg}{pointer} is a dangling pointer (it has no provenance)"
,
pointer
=
Pointer
::
<
Option
<
AllocId
>>
::
from_addr
(
*
i
),
)
}
AlignmentCheckFailed
{
required
,
has
}
=>
write!
(
f
,
...
...
compiler/rustc_middle/src/mir/interpret/pointer.rs
浏览文件 @
46956f76
...
...
@@ -181,7 +181,17 @@ impl<Tag: Provenance> fmt::Debug for Pointer<Option<Tag>> {
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
match
self
.provenance
{
Some
(
tag
)
=>
Provenance
::
fmt
(
&
Pointer
::
new
(
tag
,
self
.offset
),
f
),
None
=>
write!
(
f
,
"{:#x}"
,
self
.offset
.bytes
()),
None
=>
write!
(
f
,
"{:#x}[noalloc]"
,
self
.offset
.bytes
()),
}
}
}
impl
<
Tag
:
Provenance
>
fmt
::
Display
for
Pointer
<
Option
<
Tag
>>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
if
self
.provenance
.is_none
()
&&
self
.offset
.bytes
()
==
0
{
write!
(
f
,
"null pointer"
)
}
else
{
fmt
::
Debug
::
fmt
(
self
,
f
)
}
}
}
...
...
@@ -226,9 +236,14 @@ pub fn addr(self) -> Size
}
impl
<
Tag
>
Pointer
<
Option
<
Tag
>>
{
#[inline(always)]
pub
fn
from_addr
(
addr
:
u64
)
->
Self
{
Pointer
{
provenance
:
None
,
offset
:
Size
::
from_bytes
(
addr
)
}
}
#[inline(always)]
pub
fn
null
()
->
Self
{
Pointer
{
provenance
:
None
,
offset
:
Size
::
ZERO
}
Pointer
::
from_addr
(
0
)
}
}
...
...
src/test/ui/const-ptr/forbidden_slices.32bit.stderr
浏览文件 @
46956f76
...
...
@@ -4,7 +4,7 @@ error[E0080]: could not evaluate static initializer
LL | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| dereferencing pointer failed: null pointer is
not a valid pointer
| dereferencing pointer failed: null pointer is
a dangling pointer (it has no provenance)
| inside `std::slice::from_raw_parts::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:19:34
...
...
@@ -18,7 +18,7 @@ error[E0080]: could not evaluate static initializer
LL | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| dereferencing pointer failed: null pointer is
not a valid pointer
| dereferencing pointer failed: null pointer is
a dangling pointer (it has no provenance)
| inside `std::slice::from_raw_parts::<()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:20:33
...
...
@@ -104,7 +104,7 @@ error[E0080]: could not evaluate static initializer
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| out-of-bounds offset_from: null pointer is
not a valid pointer
| out-of-bounds offset_from: null pointer is
a dangling pointer (it has no provenance)
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
...
...
@@ -144,7 +144,7 @@ error[E0080]: could not evaluate static initializer
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed
: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
|
out-of-bounds pointer arithmetic
: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u32>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
...
LL | unsafe { self.offset(count as isize) }
...
...
@@ -205,7 +205,7 @@ error[E0080]: could not evaluate static initializer
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed
: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
|
out-of-bounds pointer arithmetic
: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u64>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
...
LL | unsafe { self.offset(count as isize) }
...
...
src/test/ui/const-ptr/forbidden_slices.64bit.stderr
浏览文件 @
46956f76
...
...
@@ -4,7 +4,7 @@ error[E0080]: could not evaluate static initializer
LL | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| dereferencing pointer failed: null pointer is
not a valid pointer
| dereferencing pointer failed: null pointer is
a dangling pointer (it has no provenance)
| inside `std::slice::from_raw_parts::<u32>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:19:34
...
...
@@ -18,7 +18,7 @@ error[E0080]: could not evaluate static initializer
LL | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| dereferencing pointer failed: null pointer is
not a valid pointer
| dereferencing pointer failed: null pointer is
a dangling pointer (it has no provenance)
| inside `std::slice::from_raw_parts::<()>` at $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
::: $DIR/forbidden_slices.rs:20:33
...
...
@@ -104,7 +104,7 @@ error[E0080]: could not evaluate static initializer
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| out-of-bounds offset_from: null pointer is
not a valid pointer
| out-of-bounds offset_from: null pointer is
a dangling pointer (it has no provenance)
| inside `ptr::const_ptr::<impl *const u32>::sub_ptr` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $SRC_DIR/core/src/slice/raw.rs:LL:COL
...
...
@@ -144,7 +144,7 @@ error[E0080]: could not evaluate static initializer
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed
: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
|
out-of-bounds pointer arithmetic
: ALLOC_ID has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u32>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
...
LL | unsafe { self.offset(count as isize) }
...
...
@@ -205,7 +205,7 @@ error[E0080]: could not evaluate static initializer
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed
: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
|
out-of-bounds pointer arithmetic
: ALLOC_ID has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u64>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
...
LL | unsafe { self.offset(count as isize) }
...
...
src/test/ui/consts/const-deref-ptr.stderr
浏览文件 @
46956f76
...
...
@@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer
--> $DIR/const-deref-ptr.rs:4:29
|
LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0xdeadbeef
is not a valid pointer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0xdeadbeef
[noalloc] is a dangling pointer (it has no provenance)
error: aborting due to previous error
...
...
src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs
浏览文件 @
46956f76
...
...
@@ -5,6 +5,6 @@ fn main() {}
// bad, will thus error in miri
const
Z2
:
i32
=
unsafe
{
*
(
42
as
*
const
i32
)
};
//~ ERROR evaluation of constant value failed
//~| is
not a valid
pointer
//~| is
a dangling
pointer
const
Z3
:
i32
=
unsafe
{
*
(
44
as
*
const
i32
)
};
//~ ERROR evaluation of constant value failed
//~| is
not a valid
pointer
//~| is
a dangling
pointer
src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr
浏览文件 @
46956f76
...
...
@@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed
--> $DIR/const_raw_ptr_ops2.rs:7:26
|
LL | const Z2: i32 = unsafe { *(42 as *const i32) };
| ^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0x2a
is not a valid pointer
| ^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0x2a
[noalloc] is a dangling pointer (it has no provenance)
error[E0080]: evaluation of constant value failed
--> $DIR/const_raw_ptr_ops2.rs:9:26
|
LL | const Z3: i32 = unsafe { *(44 as *const i32) };
| ^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0x2c
is not a valid pointer
| ^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: 0x2c
[noalloc] is a dangling pointer (it has no provenance)
error: aborting due to 2 previous errors
...
...
src/test/ui/consts/const-eval/ub-wide-ptr.32bit.stderr
浏览文件 @
46956f76
...
...
@@ -319,7 +319,7 @@ error[E0080]: could not evaluate static initializer
--> $DIR/ub-wide-ptr.rs:147:5
|
LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is
not a valid pointer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is
a dangling pointer (it has no provenance)
error[E0080]: could not evaluate static initializer
--> $DIR/ub-wide-ptr.rs:151:5
...
...
src/test/ui/consts/const-eval/ub-wide-ptr.64bit.stderr
浏览文件 @
46956f76
...
...
@@ -319,7 +319,7 @@ error[E0080]: could not evaluate static initializer
--> $DIR/ub-wide-ptr.rs:147:5
|
LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is
not a valid pointer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is
a dangling pointer (it has no provenance)
error[E0080]: could not evaluate static initializer
--> $DIR/ub-wide-ptr.rs:151:5
...
...
src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs
浏览文件 @
46956f76
...
...
@@ -11,7 +11,7 @@ const fn helper() -> Option<&'static mut i32> { unsafe {
// Undefined behaviour (integer as pointer), who doesn't love tests like this.
// This code never gets executed, because the static checks fail before that.
Some
(
&
mut
*
(
42
as
*
mut
i32
))
//~ ERROR evaluation of constant value failed
//~| 0x2a
is not a valid
pointer
//~| 0x2a
[noalloc] is a dangling
pointer
}
}
// The error is an evaluation error and not a validation error, so the error is reported
// directly at the site where it occurs.
...
...
src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr
浏览文件 @
46956f76
...
...
@@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed
LL | Some(&mut *(42 as *mut i32))
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| dereferencing pointer failed: 0x2a
is not a valid pointer
| dereferencing pointer failed: 0x2a
[noalloc] is a dangling pointer (it has no provenance)
| inside `helper` at $DIR/mut_ref_in_final_dynamic_check.rs:13:10
...
LL | const A: Option<&mut i32> = helper();
...
...
src/test/ui/consts/offset_from_ub.rs
浏览文件 @
46956f76
...
...
@@ -34,14 +34,14 @@ struct Struct {
pub
const
OFFSET_FROM_NULL
:
isize
=
{
let
ptr
=
0
as
*
const
u8
;
unsafe
{
ptr_offset_from
(
ptr
,
ptr
)
}
//~ERROR evaluation of constant value failed
//~| null pointer is
not a valid
pointer
//~| null pointer is
a dangling
pointer
};
pub
const
DIFFERENT_INT
:
isize
=
{
// offset_from with two different integers: like DIFFERENT_ALLOC
let
ptr1
=
8
as
*
const
u8
;
let
ptr2
=
16
as
*
const
u8
;
unsafe
{
ptr_offset_from
(
ptr2
,
ptr1
)
}
//~ERROR evaluation of constant value failed
//~| 0x8
is not a valid
pointer
//~| 0x8
[noalloc] is a dangling
pointer
};
const
OUT_OF_BOUNDS_1
:
isize
=
{
...
...
src/test/ui/consts/offset_from_ub.stderr
浏览文件 @
46956f76
...
...
@@ -28,13 +28,13 @@ error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:36:14
|
LL | unsafe { ptr_offset_from(ptr, ptr) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is
not a valid pointer
| ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is
a dangling pointer (it has no provenance)
error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:43:14
|
LL | unsafe { ptr_offset_from(ptr2, ptr1) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: 0x8
is not a valid pointer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: 0x8
[noalloc] is a dangling pointer (it has no provenance)
error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:52:14
...
...
src/test/ui/consts/offset_ub.stderr
浏览文件 @
46956f76
...
...
@@ -18,7 +18,7 @@ error[E0080]: evaluation of constant value failed
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed
: allocN has size 1, so pointer to 2 bytes starting at offset 0 is out-of-bounds
|
out-of-bounds pointer arithmetic
: allocN has size 1, so pointer to 2 bytes starting at offset 0 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/offset_ub.rs:8:43
...
...
@@ -32,7 +32,7 @@ error[E0080]: evaluation of constant value failed
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed
: allocN has size 100, so pointer to 101 bytes starting at offset 0 is out-of-bounds
|
out-of-bounds pointer arithmetic
: allocN has size 100, so pointer to 101 bytes starting at offset 0 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/offset_ub.rs:9:45
...
...
@@ -102,7 +102,7 @@ error[E0080]: evaluation of constant value failed
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed
: allocN has size 1, so pointer to 2 bytes starting at offset -4 is out-of-bounds
|
out-of-bounds pointer arithmetic
: allocN has size 1, so pointer to 2 bytes starting at offset -4 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/offset_ub.rs:15:49
...
...
@@ -116,7 +116,7 @@ error[E0080]: evaluation of constant value failed
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed
: allocN has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
|
out-of-bounds pointer arithmetic
: allocN has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/offset_ub.rs:17:50
...
...
@@ -130,7 +130,7 @@ error[E0080]: evaluation of constant value failed
LL | unsafe { intrinsics::offset(self, count) as *mut T }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed: 0x1 is not a valid pointer
|
out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
| inside `ptr::mut_ptr::<impl *mut u8>::offset` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
::: $DIR/offset_ub.rs:18:42
...
...
@@ -144,7 +144,7 @@ error[E0080]: evaluation of constant value failed
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed: null pointer is not a valid pointer
|
out-of-bounds pointer arithmetic: null pointer is a dangling pointer (it has no provenance)
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/offset_ub.rs:21:50
...
...
@@ -158,7 +158,7 @@ error[E0080]: evaluation of constant value failed
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed: 0x7f..f is not a valid pointer
|
out-of-bounds pointer arithmetic: 0x7f..f[noalloc] is a dangling pointer (it has no provenance)
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/offset_ub.rs:24:47
...
...
src/test/ui/consts/ptr_comparisons.stderr
浏览文件 @
46956f76
...
...
@@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
pointer arithmetic failed
: alloc3 has size $WORD, so pointer to $TWO_WORDS bytes starting at offset 0 is out-of-bounds
|
out-of-bounds pointer arithmetic
: alloc3 has size $WORD, so pointer to $TWO_WORDS bytes starting at offset 0 is out-of-bounds
| inside `ptr::const_ptr::<impl *const usize>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/ptr_comparisons.rs:58:34
...
...
src/test/ui/error-codes/E0396-fixed.stderr
浏览文件 @
46956f76
...
...
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/E0396-fixed.rs:5:28
|
LL | const VALUE: u8 = unsafe { *REG_ADDR };
| ^^^^^^^^^ dereferencing pointer failed: 0x5f3759df
is not a valid pointer
| ^^^^^^^^^ dereferencing pointer failed: 0x5f3759df
[noalloc] is a dangling pointer (it has no provenance)
error: aborting due to previous error
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录