]> Cypherpunks repositories - gostls13.git/commitdiff
fmt: document that self-recursive data structures can be fatal
authorRob Pike <r@golang.org>
Mon, 22 Sep 2014 22:35:25 +0000 (15:35 -0700)
committerRob Pike <r@golang.org>
Mon, 22 Sep 2014 22:35:25 +0000 (15:35 -0700)
Fixes #8241.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/144420043

src/fmt/doc.go

index 5af8d3e71779ef4964829791a6d553fbd30753c4..b7eaedc11ed2423b7372fa2d18d598b79927b6c6 100644 (file)
                func (x X) String() string { return Sprintf("<%s>", x) }
        convert the value before recurring:
                func (x X) String() string { return Sprintf("<%s>", string(x)) }
+       Infinite recursion can also be triggered by self-referential data
+       structures, such as a slice that contains itself as an element, if
+       that type has a String method. Such pathologies are rare, however,
+       and the package does not protect against them.
 
        Explicit argument indexes: