File: no-unaligned-access.patch

package info (click to toggle)
seqan2 2.4.0%2Bdfsg-17
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 224,224 kB
  • sloc: cpp: 256,886; ansic: 91,672; python: 8,330; sh: 995; xml: 570; makefile: 255; awk: 51; javascript: 21
file content (22 lines) | stat: -rw-r--r-- 919 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Description: use alignment-safe buffer handling.
 Currently we are using assignment to copy the contents of a variable of
 arbitrary type into a buffer, but this is not portable because the buffer
 address may not be aligned.  Use memcpy() instead, which should be
 comparable performance ut alignment-safe.
Author: Steve Langasek <steve.langasek@ubuntu.com>
Bug-Debian: https://bugs.debian.org/892223

Index: seqan2-2.4.0+dfsg/include/seqan/basic/basic_stream.h
===================================================================
--- seqan2-2.4.0+dfsg.orig/include/seqan/basic/basic_stream.h
+++ seqan2-2.4.0+dfsg/include/seqan/basic/basic_stream.h
@@ -1200,7 +1200,8 @@
 inline void
 appendRawPodImpl(TTargetValue * &ptr, TValue const & val)
 {
-    *reinterpret_cast<TValue* &>(ptr)++ = val;
+    std::memcpy(ptr, &val, sizeof(TValue));
+    ptr += sizeof(TValue);
 }
 
 template <typename TTarget, typename TValue>