diff --git a/lang/README.md b/lang/README.md index 3f565c6..c72472a 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 1c3f02c..b72539d 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 4450b5a..f22ee47 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 0000000..e69de29