Source file test/fixedbugs/bug093.go

     1  // run
     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  type S struct {
    10  }
    11  
    12  func (p *S) M() {
    13  }
    14  
    15  type I interface {
    16  	M();
    17  }
    18  
    19  func main() {
    20  	var p *S = nil;
    21  	var i I = p;  // this should be possible even though p is nil: we still know the type
    22  	i.M();  // should be possible since we know the type, and don't ever use the receiver
    23  }
    24  
    25  
    26  /*
    27  throw: ifaces2i: nil pointer
    28  SIGSEGV: segmentation violation
    29  Faulting address: 0x0
    30  pc: 0x1b7d
    31  
    32  0x1b7d?zi
    33  	throw(30409, 0, 0, ...)
    34  	throw(0x76c9, 0x0, 0x0, ...)
    35  0x207f?zi
    36  	sys·ifaces2i(31440, 0, 31480, ...)
    37  	sys·ifaces2i(0x7ad0, 0x7af8, 0x0, ...)
    38  0x136f?zi
    39  	main·main(1, 0, 1606416424, ...)
    40  	main·main(0x1, 0x7fff5fbff828, 0x0, ...)
    41  
    42  rax     0x1
    43  rbx     0x1
    44  rcx     0x33b5
    45  rdx     0x0
    46  rdi     0x1
    47  rsi     0x7684
    48  rbp     0x7684
    49  rsp     0xafb8
    50  r8      0x0
    51  r9      0x0
    52  r10     0x1002
    53  r11     0x206
    54  r12     0x0
    55  r13     0x0
    56  r14     0x7c48
    57  r15     0xa000
    58  rip     0x1b7d
    59  rflags  0x10202
    60  cs      0x27
    61  fs      0x10
    62  gs      0x48
    63  */
    64  

View as plain text