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
gccgo: reject typed non-int len/cap arguments to make #16949
Comments
This is a compiler bug. The spec says very clearly: "The size arguments n and m must be of integer type or untyped." (https://tip.golang.org/ref/spec#Making_slices_maps_and_channels). go/types reports the correct error. |
@ianlancetaylor gccgo appears to have the same problem. It accepts this code silently. |
thanks. In that case i will prepare a CL to fix checkmake in typecheck.go to reject these cases. |
CL https://golang.org/cl/28301 mentions this issue. |
…uments make(T, n, m) returns a slice of type T with length n and capacity m where "The size arguments n and m must be of integer type or untyped." https://tip.golang.org/ref/spec#Making_slices_maps_and_channels The failure to reject typed non-integer size arguments in make during compile time was uncovered after https://golang.org/cl/27851 changed the generation of makeslice calls. Fixes #16940 Updates #16949 Change-Id: Ib1e3576f0e6ad199c9b16b7a50c2db81290c63b4 Reviewed-on: https://go-review.googlesource.com/28301 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
CL 28301 fixed cmd/compile. Changing the issue to be able gccgo. |
Change https://golang.org/cl/91697 mentions this issue: |
This implements a requirement of the language spec. While we're here fix the value returned by the type method of a builtin call expression to make, although this doesn't seem to make any difference anywhere since we lower this to a runtime call before the determine_types pass anyhow. There is already a test for this error in the master repository: test/fixedbugs/issue16949.go. It just hasn't made it into the gccgo testsuite yet. Fixes golang/go#16949 Reviewed-on: https://go-review.googlesource.com/91697 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257376 138bc75d-0d04-0410-961f-82ee72b054a4
This implements a requirement of the language spec. While we're here fix the value returned by the type method of a builtin call expression to make, although this doesn't seem to make any difference anywhere since we lower this to a runtime call before the determine_types pass anyhow. There is already a test for this error in the master repository: test/fixedbugs/issue16949.go. It just hasn't made it into the gccgo testsuite yet. Fixes golang/go#16949 Reviewed-on: https://go-review.googlesource.com/91697 From-SVN: r257376
while writing test cases in https://go-review.googlesource.com/#/c/28301/ for #16940
this inconsistency turned up:
gc (tip f8555ea and playground 1.7) accept it but the go/types test does not:
trybot error:
stdlib_test.go:123: /tmp/workdir/go/test/fixedbugs/issue16940.go:49:22: invalid argument: index TCOMPLEX64(1 + 0i) (constant (1 + 0i) of type TCOMPLEX64) must be integer
\cc @josharian @dsnet @griesemer @randall77 @ianlancetaylor
The text was updated successfully, but these errors were encountered: