Why do the following programs give different outputs?
```
use fmt;
export fn main() void = {
let s: []uint = [1];
insert(s[0], 0);
fmt::println(s[0])!;
fmt::println(s[1])!;
};
```
Output:
0
2374983655
```
use fmt;
export fn main() void = {
let s: []uint = [1];
fmt::print()!;
insert(s[0], 0);
fmt::println(s[0])!;
fmt::println(s[1])!;
};
```
Output:
0
1
(Version: Hare dev+9a62f94f)
On Tue May 23, 2023 at 11:49 PM UTC, Tilman List wrote:
> export fn main() void = {
> let s: []uint = [1];
> insert(s[0], 0);
this code is incorrect - insert does the equivalent of a realloc() on
the slice. malloc currently doesn't detect the invalid free, so you'll
end up with undefined behavior instead, but in the future this code will
just crash properly
> fmt::println(s[0])!;
> fmt::println(s[1])!;
> };