You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![allow(unused)]fnmain(){letmut s = "hello".to_string();let r1 = &s as*constString;let r2 = &mut s as*mutString;assert_eq!(r1, r2);let address = 0x7fff1d72307d;// error: literal out of range for i32let r3 = address as*constString;unsafe{println!("r1 is: {}",*r1);println!("r2 is: {}",*r2);// Segmentation fault // assert_eq!(*r1, *r3)}}
错误信息
error: literal out of range for i32
--> src/main.rs:7:19
|
7 | let address = 0x7fff1d72307d;
| ^^^^^^^^^^^^^^
|
= note: `#[deny(overflowing_literals)]` on by default
= note: the literal `0x7fff1d72307d` (decimal `140733687410813`) does not fit into the type `i32` and will become `494022781i32`
= help: consider using `i64` instead
声明为 u64 即可编译通过
The text was updated successfully, but these errors were encountered:
代码清单13-10
变量定义
address
超出范围playground也报错: 链接
错误信息
声明为 u64 即可编译通过
The text was updated successfully, but these errors were encountered: