OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [fixedbugs/] [bug099.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG should not crash
2
 
3
// Copyright 2009 The Go Authors. All rights reserved.
4
// Use of this source code is governed by a BSD-style
5
// license that can be found in the LICENSE file.
6
 
7
package main
8
 
9
// Interface
10
type I interface { F() int }
11
 
12
// Implements interface
13
type S struct { }
14
func (s *S) F() int { return 1 }
15
 
16
// Allocates S but returns I
17
// Arg is unused but important:
18
// if you take it out (and the 0s below)
19
// then the bug goes away.
20
func NewI(i int) I {
21
        return new(S)
22
}
23
 
24
// Uses interface method.
25
func Use(x I) {
26
        x.F()
27
}
28
 
29
func main() {
30
        i := NewI(0);
31
        Use(i);
32
 
33
        // Again, without temporary
34
        // Crashes because x.F is 0.
35
        Use(NewI(0));
36
}
37
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.