Skip to content

Parameterize range_all testcases and harden range-dependent indexing paths#13

Merged
Coursant merged 6 commits intoSymbexpr-Cfrom
copilot/add-new-test-cases
Apr 8, 2026
Merged

Parameterize range_all testcases and harden range-dependent indexing paths#13
Coursant merged 6 commits intoSymbexpr-Cfrom
copilot/add-new-test-cases

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 8, 2026

This update adjusts the consolidated range_all testcase crate to reduce hardcoded inputs and prefer parameter-driven scenarios. It also tightens a few range/index-sensitive paths so testcase behavior remains explicit and safe under variable inputs.

  • Parameterize testcase inputs

    • Replaced embedded constants with function parameters across selected cases to better model callsite-provided values.
    • Updated signatures in numeric, interprocedural, branching, slice, and BCE boundary scenarios (e.g., loop bounds, seeds, slice ranges, opaque index).
  • Align index domains for dual-array slicing

    • In dual_array_slice_indexing, moved from y[i] on global indexing to a range-aligned y_slice matching x[slice_start..slice_end].
    • Keeps both arrays indexed under the same sliced domain.
  • Add explicit unsafe precondition guards

    • In align_and_reinterpret_slice, added early checks for required byte length and pointer alignment before from_raw_parts_mut reinterpretation.
    • Preserves testcase intent while avoiding undefined behavior from invalid input layout.
  • Clarify boundary preconditions in BCE opaque index case

    • Documented index-validity precondition for bce_failure_opaque_boundary when the opaque index is caller-provided.
pub fn align_and_reinterpret_slice(a: &mut [u8], b: &[u32; 20]) {
    let required_bytes = 20 * std::mem::size_of::<u32>();
    if a.len() < required_bytes {
        return;
    }

    unsafe {
        let ptr = a.as_mut_ptr();
        if ptr.align_offset(std::mem::align_of::<u32>()) != 0 {
            return;
        }

        let c = std::slice::from_raw_parts_mut(ptr as *mut u32, 20);
        for i in 0..20 {
            c[i] ^= b[i];
        }
    }
}

@Coursant
Copy link
Copy Markdown
Owner

Coursant commented Apr 8, 2026

tmp

@Coursant Coursant marked this pull request as ready for review April 8, 2026 12:07
@Coursant Coursant merged commit 6251cdd into Symbexpr-C Apr 8, 2026
0 of 2 checks passed
@Coursant Coursant deleted the copilot/add-new-test-cases branch April 8, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants