diff --git a/lang/README.md b/lang/README.md index 3f565c61..c72472ae 100644 --- a/lang/README.md +++ b/lang/README.md @@ -633,6 +633,30 @@ main := fn(): uint { ### 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 ```hb $W := 200 diff --git a/lang/src/son.rs b/lang/src/son.rs index 1c3f02c2..b72539dc 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -4823,6 +4823,7 @@ mod tests { fb_driver; // Purely Testing Examples; + triggering_store_in_divergent_branch; wrong_dead_code_elimination; memory_swap; very_nested_loops; diff --git a/lang/src/utils.rs b/lang/src/utils.rs index 4450b5a9..f22ee476 100644 --- a/lang/src/utils.rs +++ b/lang/src/utils.rs @@ -130,6 +130,7 @@ impl BitSet { } let (elem, bit) = Self::indexes(index); + debug_assert!(elem < data.len(), "{} < {}", elem, data.len()); let elem = unsafe { data.get_unchecked_mut(elem) }; let prev = *elem; *elem |= 1 << bit; diff --git a/lang/tests/son_tests_triggering_store_in_divergent_branch.txt b/lang/tests/son_tests_triggering_store_in_divergent_branch.txt new file mode 100644 index 00000000..e69de29b