[PATCH 1/2] doc: document max_align_t effect on ABI
Paul Eggert
eggert@cs.ucla.edu
Sun Mar 15 20:32:40 GMT 2026
* manual/lang.texi (Important Data Types): Say that ABI changes if
max_align_t changes.
---
manual/lang.texi | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/manual/lang.texi b/manual/lang.texi
index 28e7de2b2c..5f6f74ebb9 100644
--- a/manual/lang.texi
+++ b/manual/lang.texi
@@ -592,15 +592,21 @@ i.e., the greatest alignment needed by standard types.
Code can use @code{alignof (max_align_t)} when calculating space
needed for arbitrary collections of objects, so long as the objects'
types have a fundamental alignment and lack stricter alignment specifiers.
-@end deftp
In @theglibc{}, the value of @code{alignof (max_align_t)} is 16 on
most architectures. However, it is 8 on 32-bit architectures that do
not require 16-byte alignment from @code{malloc} to support predefined
types.
+Code that uses @code{max_align_t} should take into account the
+variable alignment of the type.
+For example, it is unwise for a public interface to rely on @code{max_align_t},
+as the interface's ABI can change if a different compiler defines
+@code{max_align_t} differently.
+
@strong{Compatibility Note:} The C11 standard introduced @code{max_align_t};
older compilers may lack the type.
+@end deftp
@node Data Type Measurements
@section Data Type Measurements
--
2.51.0
More information about the Libc-alpha
mailing list