adding assert for better error

This commit is contained in:
Jakub Doka 2024-11-12 21:10:42 +01:00
parent 63f2a0dac0
commit dd51961fbb
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
4 changed files with 26 additions and 0 deletions

View file

@ -633,6 +633,30 @@ main := fn(): uint {
### Purely Testing Examples ### Purely Testing Examples
#### triggering_store_in_divergent_branch
```hb
opaque := fn(): uint {
return 1 << 31
}
main := fn(): void {
a := 0
loop if a >= opaque() break else {
valid := true
b := 0
loop if b >= opaque() break else {
if b == 1 << 16 {
valid = false
break
}
b += 1
}
if valid == false continue
a += 1
}
}
```
#### very_nested_loops #### very_nested_loops
```hb ```hb
$W := 200 $W := 200

View file

@ -4823,6 +4823,7 @@ mod tests {
fb_driver; fb_driver;
// Purely Testing Examples; // Purely Testing Examples;
triggering_store_in_divergent_branch;
wrong_dead_code_elimination; wrong_dead_code_elimination;
memory_swap; memory_swap;
very_nested_loops; very_nested_loops;

View file

@ -130,6 +130,7 @@ impl BitSet {
} }
let (elem, bit) = Self::indexes(index); let (elem, bit) = Self::indexes(index);
debug_assert!(elem < data.len(), "{} < {}", elem, data.len());
let elem = unsafe { data.get_unchecked_mut(elem) }; let elem = unsafe { data.get_unchecked_mut(elem) };
let prev = *elem; let prev = *elem;
*elem |= 1 << bit; *elem |= 1 << bit;