~sircmpwn/hare#864: 
"invalid alloc size -1" when using an unbounded array type hint

export fn main() void = {
    // the problem occurs whenever the unbounded array is used: indexing, slicing, passing into a C-style variadic function, etc.
    ([]: [*]int)[0];
};

"qbe:/home/sebastian/.cache/hare/var/tmp/t.ha/b76c4e4d64e61251.ssa:14: invalid alloc size -1"

Status
REPORTED
Submitter
~sebsite
Assigned to
No-one
Submitted
1 year, 10 months ago
Updated
10 months ago
Labels
bug harec spec

~sebsite 1 year, 10 months ago

On a similar note: the spec currently says that any non-zero-size type can be passed into a C-style variadic function (and I think it makes sense to change this to also allow zero-size types once we allow zero-size bindings, just for consistency with other function calls), but it never disallows types with undefined size. Maybe we should explicitly disallow this? That being said, such a provision probably isn't necessary, provided that we take care of all other edge cases with undefined-size types, so having an object with such a type to pass in at all isn't allowed. But it might still be good to have regardless?

~sebsite 1 year, 10 months ago

The same thing happens when casting to [_]int:

[1]: [_]int;

which probably shouldn't be allowed in the first place.

~turminal 1 year, 3 days ago

Alexey Yerin referenced this ticket in commit eb38743.

~ecs 10 months ago

Alexey Yerin referenced this ticket in commit eb38743.

Register here or Log in to comment, or comment via email.