This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +11
-29
lines changed Expand file tree Collapse file tree 4 files changed +11
-29
lines changed Original file line number Diff line number Diff line change 11//@ known-bug: rust-lang/rust#125476
22//@ only-x86_64
3- pub struct Data ( [ u8 ; usize:: MAX >> 16 ] ) ;
3+ pub struct Data ( [ u8 ; usize:: MAX >> 2 ] ) ;
44const _: & ' static [ Data ] = & [ ] ;
Original file line number Diff line number Diff line change @@ -4,31 +4,13 @@ struct ReallyBig {
44}
55
66// The limit for "too big for the current architecture" is dependent on the target pointer size
7- // however it's artificially limited on 64 bits
8- // logic copied from rustc_target::abi::TargetDataLayout::obj_size_bound()
7+ // but is artificially limited due to LLVM's internal architecture
8+ // logic based on rustc_target::abi::TargetDataLayout::obj_size_bound()
99const fn max_size ( ) -> usize {
10- #[ cfg( target_pointer_width = "16" ) ]
11- {
12- 1 << 15
13- }
14-
15- #[ cfg( target_pointer_width = "32" ) ]
16- {
17- 1 << 31
18- }
19-
20- #[ cfg( target_pointer_width = "64" ) ]
21- {
22- 1 << 47
23- }
24-
25- #[ cfg( not( any(
26- target_pointer_width = "16" ,
27- target_pointer_width = "32" ,
28- target_pointer_width = "64"
29- ) ) ) ]
30- {
31- isize:: MAX as usize
10+ if usize:: BITS < 61 {
11+ 1 << ( usize:: BITS - 1 )
12+ } else {
13+ 1 << 61
3214 }
3315}
3416
Original file line number Diff line number Diff line change 11error: extern static is too large for the current architecture
2- --> $DIR/extern-static-size-overflow.rs:38 :5
2+ --> $DIR/extern-static-size-overflow.rs:20 :5
33 |
44LL | static BAZ: [u8; max_size()];
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
77error: extern static is too large for the current architecture
8- --> $DIR/extern-static-size-overflow.rs:39 :5
8+ --> $DIR/extern-static-size-overflow.rs:21 :5
99 |
1010LL | static UWU: [usize; usize::MAX];
1111 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
1313error: extern static is too large for the current architecture
14- --> $DIR/extern-static-size-overflow.rs:40 :5
14+ --> $DIR/extern-static-size-overflow.rs:22 :5
1515 |
1616LL | static A: ReallyBig;
1717 | ^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change 66type BIG = Option < [ u32 ; ( 1 <<29 ) -1 ] > ;
77
88#[ cfg( target_pointer_width = "64" ) ]
9- type BIG = Option < [ u32 ; ( 1 <<45 ) -1 ] > ;
9+ type BIG = Option < [ u32 ; ( 1 <<59 ) -1 ] > ;
1010
1111fn main ( ) {
1212 let big: BIG = None ;
You can’t perform that action at this time.
0 commit comments