Skip to content

Compilation failure on 32-bit systems #199

@BugFreeSoftware

Description

@BugFreeSoftware

In memory.go:

func (mem *Memory) UnsafeData(store Storelike) []byte {
	// see https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
	const MaxLen = 1 << 32
	length := mem.DataSize(store)
	if length >= MaxLen {
		panic("memory is too big")
	}
	return (*[MaxLen]byte)(mem.Data(store))[:length:length]
}

The 1 << 32 results in an overflow because uintptr type is 32bit on 32bit systems.
I suggest replacing it with 0xffffffff instead. That should remove the compilation error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions