[Issue 7942] Appending different string types corrupts memory
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Aug 5 18:07:27 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=7942
hsteoh at quickfur.ath.cx changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hsteoh at quickfur.ath.cx
--- Comment #8 from hsteoh at quickfur.ath.cx ---
I see two solutions to this bug: (1) transcode the string to be appended (or,
more generally, convert each value to be appended into the target type), which
is costly (but still only O(n)); (2) reject this kind of array appending at
compile-time.
I'm leaning towards (1) as being more user-friendly, going along D's motto of
"correct by default, efficient if you ask for it". (2) is a bit too restrictive
IMO, given the amount of implicit castings that we already have.
One possible compromise is to have (2) suggest std.array.appender for
concatenating strings of different element widths.
--
More information about the Digitalmars-d-bugs
mailing list