Commit 5ce78b7c authored by Russ Cox's avatar Russ Cox

spec: &x panics if x does

See golang.org/s/go12nil for the extended version.

R=golang-dev, r, adonovan
CC=golang-dev
https://golang.org/cl/12964043
parent 08fdf009
...@@ -3287,7 +3287,10 @@ or an array indexing operation of an addressable array. ...@@ -3287,7 +3287,10 @@ or an array indexing operation of an addressable array.
As an exception to the addressability requirement, <code>x</code> may also be a As an exception to the addressability requirement, <code>x</code> may also be a
(possibly parenthesized) (possibly parenthesized)
<a href="#Composite_literals">composite literal</a>. <a href="#Composite_literals">composite literal</a>.
If the evaluation of <code>x</code> would cause a <a href="#Run_time_panics">run-time panic</a>,
then the evaluation of <code>&x</code> does too.
</p> </p>
<p> <p>
For an operand <code>x</code> of pointer type <code>*T</code>, the pointer For an operand <code>x</code> of pointer type <code>*T</code>, the pointer
indirection <code>*x</code> denotes the value of type <code>T</code> pointed indirection <code>*x</code> denotes the value of type <code>T</code> pointed
...@@ -3302,6 +3305,10 @@ will cause a <a href="#Run_time_panics">run-time panic</a>. ...@@ -3302,6 +3305,10 @@ will cause a <a href="#Run_time_panics">run-time panic</a>.
&amp;Point{2, 3} &amp;Point{2, 3}
*p *p
*pf(x) *pf(x)
var x *int = nil
*x // causes a run-time panic
&*x // causes a run-time panic
</pre> </pre>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment