Skip to content

Commit

Permalink
fix inout panic checks with -cc musl-gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Jan 5, 2025
1 parent 6f0948e commit 78fce59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions vlib/builtin/array.v
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,15 @@ fn (a array) slice(start int, _end int) array {
end := if _end == max_int { a.len } else { _end } // max_int
$if !no_bounds_checking {
if start > end {
panic_n2('array.slice: invalid slice index (start>end):', start, end)
panic('array.slice: invalid slice index (start>end):' + i64(start).str() + ', ' +
i64(end).str())
}
if end > a.len {
panic_n2('array.slice: slice bounds out of range (end>=a.len):', end, a.len)
panic('array.slice: slice bounds out of range (' + i64(end).str() + ' >= ' +
i64(a.len).str() + ')')
}
if start < 0 {
panic_n('array.slice: slice bounds out of range (start<0):', start)
panic('array.slice: slice bounds out of range (start<0):' + start.str())
}
}
// TODO: integrate reference counting
Expand Down
3 changes: 2 additions & 1 deletion vlib/builtin/builtin.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,8 @@ pub fn gc_memory_use() usize {
fn v_fixed_index(i int, len int) int {
$if !no_bounds_checking {
if i < 0 || i >= len {
panic_n2('fixed array index out of range (index, len):', i, len)
panic('fixed array index out of range (index: ' + i64(i).str() + ', len: ' +
i64(len).str() + ')')
}
}
return i
Expand Down

0 comments on commit 78fce59

Please sign in to comment.