code
stringlengths
10
1.34M
language
stringclasses
1 value
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { var b [0]byte s := string(b[0:]) // out of bounds trap if s != "" { panic("bad convert") } var b1 = [5]byte{'h', 'e',...
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "os" func main() { ok := true; var a, b, c, x, y, z int; f := func() int { b--; return -b }; // this fails on 6g: apparently ...
Go
// compile // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main type Foo interface { } type T struct {} func (t *T) foo() {} func main() { t := new(T); var i interface {}; f, ok := i.(Foo); _,...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package one type T1 int type T2 []T1 type T3 T2 func F1(T2) { } func (p *T1) M1() T3 { return nil } func (p T3) M2() { }
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // The gccgo compiler would fail on the import statement. // two.go:10:13: error: use of undefined type ‘one.T2’ package two import "./one" var V one.T3
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "bufio" "./io" goio "io" ) func main() { // The errors here complain that io.X != io.X // for different values of io so they shoul...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package io type Writer interface { WrongWrite() } type SectionReader struct { X int } func SR(*SectionReader) {}
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { k, l, m := 0,0,0; _, _, _ = k, l, m; }
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func dosplit(wait chan int ){ select { case <-wait: } } func main() { }
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Test case for issue 471. This file shouldn't compile. package main const a *int = 1 // ERROR "convert|wrong|invalid" const b [2]int =...
Go
// compile // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // used to crash the compiler package bug235 type T struct { x [4]byte } var p *T var v = *p
Go
// run // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main type S1 struct { i int } type S2 struct { i int } type S3 struct { S1 S2 } type S4 struct { S3 S1 } func main() { var s4 S4 if s...
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { var cu0 uint16 = '\u1234'; var cU1 uint32 = '\U00101234'; _, _ = cu0, cU1; } /* bug13.go:4: missing ' bug13.go:4: syntax ...
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Used to crash the compiler. // http://code.google.com/p/go/issues/detail?id=158 package main type A struct { a A } // ERROR "recursive" func...
Go
// errorcheck // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 2276. // Check that the error messages says // bug381.go:29: unsafe.Alignof(0) not used // and not // bug381.go:29: 4 not used // Is...
Go
// compile // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 2549 /* Used to die with missing typecheck: [7f5bf07b4438] . AS l(45) . . NAME-main.autotmp_0017 u(1) a(1) l(45) x(0+0) class(PAU...
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main const c = 3 var x = c.String() // ERROR "String"
Go
// compile // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 1368. package main func main() { a := complex(2, 2) a /= 2 } /* bug315.go:13: internal compiler error: optoas: no entry DIV-complex */...
Go
// build // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func f1() { type T struct { x int } } func f2() { type T struct { x float64 } } func main() { f1() f2() } /* 1606416576: co...
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main type I interface { m() } type T struct { m func() } type M struct {} func (M) m() {} func main() { var t T var m M var i I ...
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { var s2 string = "\a\b\f\n\r\t\v"; // \r is miscompiled _ = s2; } /* main.go.c: In function ‘main_main’: main.go.c:20: err...
Go
// compile // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Test cases for conversion syntax. package main type ( A [3]int S struct { x int } P *S F func(x int) int I interface { m(x int) int ...
Go
// errorcheck // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main // type T int func main() {} // issue 1474 // important: no newline on end of next line. // 6g used to print <epoch> instead of...
Go
// run // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 2423 package main func main() { var x interface{} = "hello" switch x { case "hello": default: println("FAIL") } }
Go
// run // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://code.google.com/p/go/issues/detail?id=846 package main func x() (a int, b bool) { defer func(){ a++ }() a, b = y() return } func x2(...
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "unsafe" func main() { // works addr := uintptr(0x234) x1 := (*int)(unsafe.Pointer(addr)) // fails x2 := (*int)(unsafe.Point...
Go
// run // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { m := make(map[string][1000]byte) m["hi"] = [1000]byte{1} v := m["hi"] for k, vv := range m { if k != "hi" || stri...
Go
// compile // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // issue 1016 package bug309 func foo(t interface{}, c chan int) { switch v := t.(type) { case int: select { case <-c: // bug was: inter...
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bug0 type t0 struct { } var V0 t0
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bug1 import "./bug0" // This is expected to fail--t0 is in package bug0 and should not be // visible here in package bug1. The test for failure is i...
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package p1 type T <-chan int var x = make(chan T)
Go
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package p2 import _ "./p1"
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import os "os" type _ os.FileInfo func f() (os int) { // In the next line "os" should refer to the result variable, not // to th...
Go
// errorcheck // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main type T int func (T) m() {} // GCCGO_ERROR "previous" func (T) m() {} // ERROR "T[.]m redeclared|redefinition" func (*T) p() {} /...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package pkg type T struct {} var E T
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func f9(a int) (i int, f float64) { i := 9 // ERROR "redecl|no new" f := float64(9) // ERROR "redecl|no new" return i, ...
Go
// compile // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // gccgo crashed compiling this. package main type S struct { f [2][]int } func F() (r [2][]int) { return } func main() { var a []S a[0].f =...
Go
// compile // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { L1: L2: for i := 0; i < 10; i++ { print(i) break L2 } L3: ; L4: for i := 0; i < 10; i++ { print(i) break L4...
Go
// errorcheck // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://code.google.com/p/go/issues/detail?id=808 package main type A [...]int // ERROR "outside of array literal"
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { switch { // empty switch is allowed according to syntax // unclear why it shouldn't be allowed } switch tag := 0; tag ...
Go
// [ $A == 6 ] || errchk $G -e $D/$F.go // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 2444 package main func main() { var arr [1000200030]int // ERROR "type .* too large" arr_bkup := arr _ ...
Go
// compile // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 1811. // gccgo failed to compile this. package p type E interface{} type I interface { E E }
Go
// compile // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bug232 type I interface { X(...int) }
Go
// run // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import . "testing" // defines top-level T type S struct { T int } func main() { _ = &S{T: 1} // should work }
Go
// errorcheck // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "fmt" func main() { // invalid use of goto. // do whatever you like, just don't crash. i := 42 a := []*int{&i, &i, &i,...
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { if ; false {} // compiles; should be an error (should be simplevardecl before ;) }
Go
// runoutput // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 3804 // test all possible float -> integer conversions package main import ( "bytes" "fmt" "strings" ) var ( intWidths = []int{8,...
Go
// run // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main var a [10]int var b [1e1]int func main() { if len(a) != 10 || len(b) != 10 { println("len", len(a), len(b)) panic("fail") } }
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package P var x int func foo() { print(P.x); // ERROR "undefined" } /* uetli:~/Source/go1/test/bugs gri$ 6g bug085.go bug085.go:6: P: undefi...
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { var s string; s = "0000000000000000000000000000000000000000000000000000000000"[0:7]; _ = s; } /* uetli:~/Source/go1/test...
Go
// errorcheck // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 2500 package foo // Check that we only get root cause message, no further complaints about r undefined func (r *indexWriter) foo() {}...
Go
// compiledir // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. ignored
Go
// errorcheck // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main type T struct{} type P *T func (t *T) Meth() {} func (t T) Meth2() {} func main() { t := &T{} p := P(t) p.Meth() // ERROR "u...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "./p" func main() {} var _ p.A
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package p type A struct { s struct{int} } func (a *A) f() { a.s = struct{int}{0} }
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { var buf [10]int; for ; len(buf); { // ERROR "bool" } } /* uetli:/home/gri/go/test/bugs gri$ 6g bug209.go bug209....
Go
// errorcheck // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 2627 -- unsafe.Pointer type isn't handled nicely in some errors package main import "unsafe" func main() { var x *int _ = unsafe.Po...
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func f() { v := 1 << 1025; // ERROR "overflow|stupid shift" _ = v }
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "fmt" func f0() string { const f = 3.141592; return fmt.Sprintf("%v", float64(f)); } func f1() string { const f = 3.141592; ...
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { var x int; switch x { case 0: {} case 1: x = 0; } } /* bug0.go:8: case statement out of place */
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main var ( nf int x, y, z = f(), f(), f() m = map[string]string{"a": "A"} a, aok = m["a"] b, bok = m["b"] ) func look(s str...
Go
// compiledir // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ignored
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { i5 := 5; switch { // compiler crash fixable with 'switch true' case i5 < 5: dummy := 0; _ = dummy; case i5 == 5: dummy...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package lib type I interface { m() string } type T struct{} // m is not accessible from outside this package. func (t *T) m() string { return "lib.T.m" }
Go
// errorcheck // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 873, 2162 package foo func f(x interface{}) { switch t := x.(type) { // ERROR "declared and not used" case int: } } func g(x int...
Go
// errorcheck // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Test that a syntax error caused by an unexpected EOF // gives an error message with the correct line number. // // https://code.google.com/p/...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "./p" ) type Exported interface { private() } type Implementation struct{} func (p *Implementation) private() {} func main() { //...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package p type Exported interface { private() } type Implementation struct{} func (p *Implementation) private() { println("p.Implementation.private()") } v...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package one // Issue 2877 type T struct { f func(t *T, arg int) g func(t T, arg int) } func (t *T) foo(arg int) {} func (t T) goo(arg int) {} func (t *T) ...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Use the functions in one.go so that the inlined // forms get type-checked. package two import "./one" func use() { var r one.T r.F() }
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "os" type S struct { i int } func (p *S) Get() int { return p.i } type Empty interface { } type Getter interface { Get() int; }...
Go
// compile // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://code.google.com/p/go/issues/detail?id=990 package main func main() { defer func() { if recover() != nil { panic("non-nil recover"...
Go
// run // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main func main() { c := make(chan int, 1) dummy := make(chan int) v := 0x12345678 for i := 0; i < 10; i++ { // 6g had a bug that caused ...
Go
// compile // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 2576 package bug type T struct { a int } func f(t T) { switch _, _ = t.a, t.a; {} }
Go
// compile // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // gccgo gave an invalid error ("floating point constant truncated to // integer") compiling this. package p const C = 1<<63 - 1 func F(i int64) ...
Go
// compile // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // these used to fail because the runtime // functions that get called to implement them // expected string, not T. package main type T string fun...
Go
// compile // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Crashed gccgo. package p type S struct { f interface{} } func F(p *S) bool { v := p.f switch a := v.(type) { case nil: _ = a return t...
Go
// run // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main var x [10][0]byte var y = make([]struct{}, 10) func main() { if &x[1] != &x[2] { println("BUG: bug352 [0]byte") } if &y[1] != &y[2]...
Go
// errorcheck // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package p func f(i int) int { return i } var i = func() int {a := f(i); return a}() // ERROR "initialization loop"
Go
// errorcheck // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main // Issue 2623 var m = map[string]int { "abc":1, 1:2, // ERROR "cannot use 1.*as type string in map key|incompatible type" }
Go
// run // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "runtime" "strings" ) func f() { var x *string for _, i := range *x { // THIS IS LINE 17 println(i) } } func g() { }...
Go
// compile // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package P const a = 0; func f(a int) { a = 0; } /* bug161.go:8: operation LITERAL not allowed in assignment context */
Go
// run // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main type ( Point struct { x, y float64 } Polar Point ) func main() { } /* bug7.go:5: addtyp: renaming Point to Polar main.go.c:14: erro...
Go
// errorcheck // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // 6g accepts the program below even though it is syntactically incorrect: // Each statement in the list of statements for each case clause must...
Go
// errorcheck // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This is a test case for issue 804. package main func f() [10]int { return [10]int{} } var m map[int][10]int func main() { f()[1] = 2 //...
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package one type I1 interface { f() } type S1 struct { } func (s S1) f() { } func F1(i1 I1) { }
Go
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package two import "./one" type S2 struct { one.S1 }
Go
// compile // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Used to run out of registers on 8g. Issue 868. package main func main() { var r uint32 var buf [4]byte a := buf[0:4] r = (((((uint32(a[3]...
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main var v1 = ([10]int)(nil); // ERROR "illegal|nil|invalid" var v2 [10]int = nil; // ERROR "illegal|nil|incompatible" var v3 [10]int; v...
Go
// compile // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main type I1 interface {} type I2 interface { pr() } func e() I1; var i1 I1; var i2 I2; func main() { i2 = e().(I2); // bug089.go:16: ...
Go
// compile // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "unsafe" func main() { var x int a := uint64(uintptr(unsafe.Pointer(&x))) b := uint32(uintptr(unsafe.Pointer(&x))) c :=...
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bug0 type T struct { i int }
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bug1 import "./bug0" type T struct { t bug0.T }
Go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bug2 import _ "./bug1" import "./bug0" type T2 struct { t bug0.T } func fn(p *T2) int { // This reference should be invalid, because bug0.T.i is lo...
Go
// compiledir // Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ignored
Go
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Verify that illegal assignments with both explicit and implicit conversions of literals are detected. // Does not compile. package main // e...
Go
// true // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main // can't use local path with -u, use -I. instead import "pkg" // ERROR "import unsafe package" func main() { print(pkg.Float32bits(1.0...
Go
// true // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // a package that uses unsafe on the inside but not in it's api package pkg import "unsafe" // this should be inlinable func Float32bits(f float32) ...
Go
// $G $D/pkg.go && pack grc pkg.a pkg.$A 2> /dev/null && rm pkg.$A && errchk $G -I. -u $D/main.go // rm -f pkg.a // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ignored
Go
// $G $D/pkg.go && pack grcS pkg.a pkg.$A 2> /dev/null && rm pkg.$A && $G -I. -u $D/main.go // rm -f pkg.a // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ignored
Go