Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: erroneously accepts array types with non-constant length #28079

Closed
mdempsky opened this issue Oct 8, 2018 · 6 comments

Comments

Projects
None yet
4 participants
@mdempsky
Copy link
Member

commented Oct 8, 2018

cmd/compile accepts this source:

package p

import "unsafe"

type T [uintptr(unsafe.Pointer(nil))]int

go/types correctly rejects it with "array length must be constant".

Related #28078.

@mdempsky

This comment has been minimized.

Copy link
Member Author

commented Oct 8, 2018

var x [0]int
x[uintptr(unsafe.Pointer(nil))] = 0

should be valid, but cmd/compile rejects it. (go/types correctly accepts it.)

@mdempsky

This comment has been minimized.

Copy link
Member Author

commented Oct 8, 2018

Valid, but rejected by cmd/compile:

var x [10]int
_ = x[3 : uintptr(unsafe.Pointer(nil))]
@mdempsky

This comment has been minimized.

Copy link
Member Author

commented Oct 10, 2018

var _ = complex(1<<uintptr(unsafe.Pointer(nil)), 0)

Invalid, but accepted by cmd/compile.

gotype gives "invalid operation: shifted operand 1 (type float64) must be integer".

@bcmills

This comment has been minimized.

Copy link
Member

commented Oct 23, 2018

@bcmills bcmills added this to the Unplanned milestone Oct 23, 2018

@griesemer griesemer self-assigned this Oct 23, 2018

@griesemer

This comment has been minimized.

Copy link
Contributor

commented Oct 23, 2018

Not urgent. Marked unplanned.

@gopherbot

This comment has been minimized.

Copy link

commented Nov 27, 2018

Change https://golang.org/cl/151320 mentions this issue: cmd/compile: don't convert non-Go-constants to OLITERALs

@gopherbot gopherbot closed this in eb6c433 Nov 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.