wcscpy broken
Ulrich Weigand
weigand@immd1.informatik.uni-erlangen.de
Mon Feb 3 00:33:00 GMT 2003
Ulrich Drepper wrote:
> Broken compilers don't count as when looking at "validly generated"
> codo. The single increment form had performance advantages and any kind
> of argumentation which has only the benefit to help platforms with
> broken tools, ABIs, concepts will fall on deaf ears. Require people to
> use a sane compiler.
I have no problem with requiring people to use a fixed compiler in the
particular case I originally described. I just think that there are
other cases where non-aligned wide strings could validly occur, as I
mentioned.
Of course, it is possible to keep a single increment form of wcscpy
that still allows arbitrary alignment; something like
wchar_t *wcp = (wchar_t *) src;
wint_t c;
const ptrdiff_t off = (char *)dest - (char *)(src + 1);
do
{
c = *wcp++;
*(wchar_t *)((char *)wcp + off) = c;
}
while (c != L'\0');
should do just fine (and generate even marginally better code than
the original form).
Bye,
Ulrich
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de
More information about the Libc-alpha
mailing list