klayout icon indicating copy to clipboard operation
klayout copied to clipboard

undefined behavior when `fast_copy` does misaligned reads and writes

Open rocallahan opened this issue 1 year ago • 6 comments

In tlStream.cc fast_copy does

    while (n >= sizeof (unsigned long)) {
      *tl++ = *sl++;

and there's no guarantee that tl and sl are correctly aligned. This is undefined behavior in C and C++.

Why didn't you just use memcpy here?

rocallahan avatar Jul 26 '24 02:07 rocallahan