1/1000 events do happen sometimes...

This commit is contained in:
Ralf Jung 2022-10-09 13:40:49 +02:00
parent eb29c9e130
commit ccbc63be5e
6 changed files with 6 additions and 6 deletions

View file

@ -7,7 +7,7 @@ struct MuchAlign;
fn main() {
// Try many times as this might work by chance.
for _ in 0..10 {
for _ in 0..20 {
let buf = [0u32; 256];
// `buf` is sufficiently aligned for `layout.align` on a `dyn Debug`, but not
// for the actual alignment required by `MuchAlign`.

View file

@ -11,7 +11,7 @@ struct Foo {
fn main() {
// Try many times as this might work by chance.
for _ in 0..10 {
for _ in 0..20 {
let foo = Foo { x: 42, y: 99 };
let p = &foo.x;
let i = *p; //~ERROR: alignment 4 is required

View file

@ -3,7 +3,7 @@
fn main() {
// Try many times as this might work by chance.
for _ in 0..10 {
for _ in 0..20 {
let x = [2u16, 3, 4, 5]; // Make it big enough so we don't get an out-of-bounds error.
let x = &x[0] as *const _ as *const *const u8; // cast to ptr-to-ptr, so that we load a ptr
// This must fail because alignment is violated. Test specifically for loading pointers,

View file

@ -6,7 +6,7 @@ fn main() {
// (This would be missed if u8 allocations are *always* at odd addresses.)
//
// Try many times as this might work by chance.
for _ in 0..10 {
for _ in 0..20 {
let x = [0u8; 4];
let ptr = x.as_ptr().wrapping_offset(1).cast::<u16>();
let _val = unsafe { *ptr }; //~ERROR: but alignment

View file

@ -4,7 +4,7 @@
fn main() {
// Try many times as this might work by chance.
for i in 0..10 {
for i in 0..20 {
let x = i as u8;
let x = &x as *const _ as *const [u32; 0];
// This must fail because alignment is violated. Test specifically for loading ZST.

View file

@ -22,7 +22,7 @@ fn align_to() {
fn main() {
// Do this a couple times in a loop because it may work "by chance".
for _ in 0..10 {
for _ in 0..20 {
manual_alignment();
align_to();
}