File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ //@ compile-flags: -Copt-level=3 -Z merge-functions=disabled
2+ //@ needs-deterministic-layouts
3+
4+ #![ crate_type = "lib" ]
5+
6+ // Regression test for #152788: `size_of_val(p) == 0` folds to `false` for
7+ // DSTs with a non-zero prefix (nuw+nsw on offset+tail, assume on rounding).
8+
9+ pub struct Foo < T : ?Sized > ( pub [ u32 ; 3 ] , pub T ) ;
10+
11+ // CHECK-LABEL: @size_of_val_dyn_not_zero
12+ #[ no_mangle]
13+ pub fn size_of_val_dyn_not_zero ( p : & Foo < dyn std:: fmt:: Debug > ) -> bool {
14+ // CHECK: ret i1 false
15+ std:: mem:: size_of_val ( p) == 0
16+ }
17+
18+ // CHECK-LABEL: @size_of_val_slice_u8_not_zero
19+ #[ no_mangle]
20+ pub fn size_of_val_slice_u8_not_zero ( p : & Foo < [ u8 ] > ) -> bool {
21+ // CHECK: ret i1 false
22+ std:: mem:: size_of_val ( p) == 0
23+ }
24+
25+ // CHECK-LABEL: @size_of_val_slice_i32_not_zero
26+ #[ no_mangle]
27+ pub fn size_of_val_slice_i32_not_zero ( p : & Foo < [ i32 ] > ) -> bool {
28+ // CHECK: ret i1 false
29+ std:: mem:: size_of_val ( p) == 0
30+ }
You can’t perform that action at this time.
0 commit comments