File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,15 @@ It may take optional keyword arguments:
5959
6060When `data` is not given, the buffer will be both readable and writable by default.
6161
62+ !!! warning "Passing `data` as scratch space to `IOBuffer` with `write=true` may give unexpected behavior"
63+ Once `write` is called on an `IOBuffer`, it is best to consider any
64+ previous references to `data` invalidated; in effect `IOBuffer` "owns"
65+ this data until a call to `take!`. Any indirect mutations to `data`
66+ could lead to undefined behavior by breaking the abstractions expected
67+ by `IOBuffer`. If `write=true` the IOBuffer may store data at any
68+ offset leaving behind arbitrary values at other offsets. If `maxsize > length(data)`,
69+ the IOBuffer might re-allocate the data entirely, which
70+ may or may not be visible in any outstanding bindings to `array`.
6271# Examples
6372```jldoctest
6473julia> io = IOBuffer();
You can’t perform that action at this time.
0 commit comments