Re: [go-nuts] What's the maximum array length?

2022-10-27 Thread Kurtis Rader
On Thu, Oct 27, 2022 at 9:16 PM Rob Pike  wrote:

> For those watching at home, the error message is
>
> compile: data too large
>

Yes, but as I noted in my reply if you remove the composite literal
initializer (i.e., reducing it to just var x = [1 << 34]byte{}) I get this
error (using Go 1.19 on macOS):

./x.go:3:5: main.x: symbol too large (17179869184 bytes > 20 bytes)

That appears to be the primary limit. That including a composite literal
initializer that exceeds that limit, causing a more ambiguous error, seems
like a related, but secondary, issue.


> On Fri, Oct 28, 2022 at 12:43 PM eric...@arm.com 
> wrote:
>
>> The spec says that " The length is part of the array's type; it must
>> evaluate to a non-negative constant 
>> representable  by a value of
>> type int. ", so on a 64-bit environment, I assume that the maximum array
>> length should be math.MaxInt64, am I right ? But the following code doesn't
>> compile:
>>
>> package main
>> var x = [1<<34]byte{1<<23: 23, 1<<24: 24, 1<<33:33
>>
>>
-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD-QnJbRS3Vj-LWXKePOp2Q3FGi15tpEOhFbd2%3Df%3D5fEfQ%40mail.gmail.com.


Re: [go-nuts] What's the maximum array length?

2022-10-27 Thread Rob Pike
Ah, and here's why. cmd/internal/obj/objfile as a 32-bit data size.

if int64(uint32(dataOff)) != dataOff {

log.Fatalf("data too large")

}




On Fri, Oct 28, 2022 at 3:15 PM Rob Pike  wrote:

> For those watching at home, the error message is
>
> compile: data too large
>
> -rob
>
>
>
> On Fri, Oct 28, 2022 at 12:43 PM eric...@arm.com 
> wrote:
>
>> The spec says that " The length is part of the array's type; it must
>> evaluate to a non-negative constant 
>> representable  by a value of
>> type int. ", so on a 64-bit environment, I assume that the maximum array
>> length should be math.MaxInt64, am I right ? But the following code doesn't
>> compile:
>>
>> package main
>> var x = [1<<34]byte{1<<23: 23, 1<<24: 24, 1<<33:33}
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/e295dd1c-2abd-4709-a6c4-1252ef635b5en%40googlegroups.com
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOXNBZQsnk%3DyD0jCd4Fo1h1Y4q_7msHzi7WhQtgQnBi9HrDtSA%40mail.gmail.com.


Re: [go-nuts] What's the maximum array length?

2022-10-27 Thread Rob Pike
For those watching at home, the error message is

compile: data too large

-rob



On Fri, Oct 28, 2022 at 12:43 PM eric...@arm.com  wrote:

> The spec says that " The length is part of the array's type; it must
> evaluate to a non-negative constant 
> representable  by a value of
> type int. ", so on a 64-bit environment, I assume that the maximum array
> length should be math.MaxInt64, am I right ? But the following code doesn't
> compile:
>
> package main
> var x = [1<<34]byte{1<<23: 23, 1<<24: 24, 1<<33:33}
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/e295dd1c-2abd-4709-a6c4-1252ef635b5en%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOXNBZQWRB-iAdZ2KHV2TxEWBywg7BjpijS9pWC0PBL_OZk8FQ%40mail.gmail.com.


[go-nuts] What's the maximum array length?

2022-10-27 Thread eric...@arm.com
The spec says that " The length is part of the array's type; it must 
evaluate to a non-negative constant  
representable  by a value of 
type int. ", so on a 64-bit environment, I assume that the maximum array 
length should be math.MaxInt64, am I right ? But the following code doesn't 
compile:

package main
var x = [1<<34]byte{1<<23: 23, 1<<24: 24, 1<<33:33}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e295dd1c-2abd-4709-a6c4-1252ef635b5en%40googlegroups.com.