File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1103,6 +1103,9 @@ fn univariant<
11031103 inverse_memory_index. into_iter ( ) . map ( |it| it. index ( ) as u32 ) . collect ( )
11041104 } ;
11051105 let size = min_size. align_to ( align. abi ) ;
1106+ if size. bytes ( ) >= dl. obj_size_bound ( ) {
1107+ return None ;
1108+ }
11061109 let mut layout_of_single_non_zst_field = None ;
11071110 let mut abi = Abi :: Aggregate { sized } ;
11081111 // Try to make this a Scalar/ScalarPair.
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ pub(super) fn sanity_check_layout<'tcx>(
1919 if layout. size . bytes ( ) % layout. align . abi . bytes ( ) != 0 {
2020 bug ! ( "size is not a multiple of align, in the following layout:\n {layout:#?}" ) ;
2121 }
22+ if layout. size . bytes ( ) >= cx. tcx . data_layout . obj_size_bound ( ) {
23+ bug ! ( "size is too large, in the following layout:\n {layout:#?}" ) ;
24+ }
2225
2326 if !cfg ! ( debug_assertions) {
2427 // Stop here, the rest is kind of expensive.
Original file line number Diff line number Diff line change 1+ // build-fail
2+ // compile-flags: --target i686-unknown-linux-gnu --crate-type lib
3+ // needs-llvm-components: x86
4+ #![ feature( no_core, lang_items) ]
5+ #![ allow( internal_features) ]
6+ #![ no_std]
7+ #![ no_core]
8+
9+ // 0x7fffffff is fine, but after rounding up it becomes too big
10+ #[ repr( C , align( 2 ) ) ]
11+ pub struct Example ( [ u8 ; 0x7fffffff ] ) ;
12+
13+ pub fn lib ( _x : Example ) { } //~ERROR: too big for the current architecture
14+
15+ #[ lang = "sized" ]
16+ pub trait Sized { }
17+ #[ lang = "copy" ]
18+ pub trait Copy : Sized { }
Original file line number Diff line number Diff line change 1+ error: values of the type `Example` are too big for the current architecture
2+ --> $DIR/too-big-with-padding.rs:12:1
3+ |
4+ LL | pub fn lib(_x: Example) {}
5+ | ^^^^^^^^^^^^^^^^^^^^^^^
6+
7+ error: aborting due to previous error
8+
You can’t perform that action at this time.
0 commit comments