This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: wcscpy broken


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]