summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-10-03 16:26:05 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-10-04 09:28:52 -0400
commit2c3bf8d6f064c5ccab1d57f3eb82381ff445cc4a (patch)
tree157b8a9016def531726cc8261d558f00cbf32117
parente3ebe734ab047418a3c26cd7eca53fc7f4f60111 (diff)
downloadbfs-2c3bf8d6f064c5ccab1d57f3eb82381ff445cc4a.tar.xz
dstring: Limit the special dchar typedef to lint builds
Clang still thinks that alignof(dstr[1]) == 2, so out of an abundance of caution, don't mess with dchar alignment in normal builds.
-rw-r--r--src/dstring.h9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/dstring.h b/src/dstring.h
index 91a600c..6496a4f 100644
--- a/src/dstring.h
+++ b/src/dstring.h
@@ -14,19 +14,14 @@
#include <stddef.h>
/** Marker type for dynamic strings. */
-#if __clang__
+#if BFS_LINT && __clang__
// Abuse __attribute__(aligned) to make a type that allows
//
// dchar * -> char *
//
-// conversions, but warns on
+// conversions, but warns (with Clang's -Walign-mismatch) on
//
// char * -> dchar *
-//
-// (with Clang's -Walign-mismatch). The alignment is not a lie, due to the
-// layout of struct dstring, but we only enable this on Clang because GCC
-// tracks alignment through array accesses, reporting UBSan errors on (and
-// maybe even miscompiling) dstr[1].
typedef __attribute__((aligned(alignof(size_t)))) char dchar;
#else
typedef char dchar;