File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1554,7 +1554,11 @@ func (c *compilerContext) maxSliceSize(elementType llvm.Type) uint64 {
1554
1554
// Determine the maximum allowed size for a slice. The biggest possible
1555
1555
// pointer (starting from 0) would be maxPointerValue*sizeof(elementType) so
1556
1556
// divide by the element type to get the real maximum size.
1557
- maxSize := maxPointerValue / c .targetData .TypeAllocSize (elementType )
1557
+ elementSize := c .targetData .TypeAllocSize (elementType )
1558
+ if elementSize == 0 {
1559
+ elementSize = 1
1560
+ }
1561
+ maxSize := maxPointerValue / elementSize
1558
1562
1559
1563
// len(slice) is an int. Make sure the length remains small enough to fit in
1560
1564
// an int.
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ func main() {
19
19
printslice ("foo[1:2]" , foo [1 :2 ])
20
20
println ("sum foo:" , sum (foo ))
21
21
22
+ // creating a slice of uncommon base type
23
+ assert (len (make ([]struct {}, makeInt (4 ))) == 4 )
24
+
22
25
// creating a slice with uncommon len, cap types
23
26
assert (len (make ([]int , makeInt (2 ), makeInt (3 ))) == 2 )
24
27
assert (len (make ([]int , makeInt8 (2 ), makeInt8 (3 ))) == 2 )
You can’t perform that action at this time.
0 commit comments