-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
breakingImplementing this issue could cause existing code to no longer compile or have different behavior.Implementing this issue could cause existing code to no longer compile or have different behavior.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.
Milestone
Description
Unclear behaviour on array access
fn fillArray(src: &const [24]u8, dest: &[24]u8) -> usize {
var idx: usize = 24;
// access of of bounds
dest[1] = src[0];
// copies everything
// dest[0] = src[0];
// error: expected type '[24]u8', found 'u8'
//dest[1] = u8('a');
(*dest)[14] = 'b';
(*dest)[3] = 'c';
// access out of bounds
dest[idx] = src[0];
// segfault
//(*dest)[idx] = (*src)[0];
// error: index 24 outside array of size 24
//(*dest)[24] = 'b';
return (*dest).len;
}
pub fn main() -> %void {
var s : [24]u8 = []u8{0} ** 24;
var ss : [24]u8 = []u8{'a'} ** 24;
const l = fillArray(&ss, &s);
if (s[0] == 'a') {
s[1] = s[0];
}
}
Metadata
Metadata
Assignees
Labels
breakingImplementing this issue could cause existing code to no longer compile or have different behavior.Implementing this issue could cause existing code to no longer compile or have different behavior.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.