Does anyone care if Tuple.slice() returns by ref?
tsbockman via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 6 19:16:48 PST 2016
I want to do a quick survey of the community, to help figure out
the best way to fix Phobos issue 15645: Tuple.slice() causes
memory corruption.
https://issues.dlang.org/show_bug.cgi?id=15645
BACKGROUND: Currently, Tuple.slice() returns an actual slice: an
interior pointer to some part of the original Tuple.
However, alignment issues require that the return type be
something other than a standard Tuple to maintain memory safety.
My PR adds a hidden padding member to the beginning of the return
type: https://github.com/D-Programming-Language/phobos/pull/3973
Saurabh Das has submitted an alternative, and arguably more
elegant solution (WIP):
https://github.com/D-Programming-Language/phobos/pull/3975
His version simply returns the slice by value, rather than
reference. This solves the memory safety issue, but it is a
potentially significant breaking change.
THE QUESTION: Does anyone care? Is anyone writing code that
depends upon the ref-ness of Tuple.slice()'s return type?
(If we go with Saurabh Das' approach, we'll deprecate the old
slice() by ref method, so it there won't be any *silent* breakage
either way.)
VOTE HERE:
http://www.polljunkie.com/poll/rtjndn/fixing-ds-tupleslice-issue-15645
RESULTS (so far):
http://www.polljunkie.com/poll/kpnmtk/fixing-ds-tupleslice-issue-15645/view
More information about the Digitalmars-d
mailing list