https://github.com/mugiwaraluffy56 created https://github.com/llvm/llvm-project/pull/179031
`__alignof__` returns the "preferred" alignment, which can differ from the actual ABI required alignment on some architectures. This can give misleading results in the generated layout tests when testing ABI compatibility. Use `_Alignof` (C11 standard keyword) instead, which returns the actual ABI required alignment. Fixes #179007. >From 1045b4cab575c3165be8a0b25ef18cbde8c8ccb3 Mon Sep 17 00:00:00 2001 From: mugiwaraluffy56 <[email protected]> Date: Sat, 31 Jan 2026 18:19:42 +0530 Subject: [PATCH] [ABITest] Use _Alignof instead of __alignof__ for ABI alignment __alignof__ returns the 'preferred' alignment which may differ from the actual ABI-required alignment on some architectures. This can give misleading results in generated layout tests. Use _Alignof (C11 standard) instead, which returns the actual ABI-required alignment of a type. Fixes #179007. --- clang/utils/ABITest/ABITestGen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/ABITest/ABITestGen.py b/clang/utils/ABITest/ABITestGen.py index 119b3299ffa60..6dcf75f69ea8b 100755 --- a/clang/utils/ABITest/ABITestGen.py +++ b/clang/utils/ABITest/ABITestGen.py @@ -306,7 +306,7 @@ def printSizeOfType(self, prefix, name, t, output=None, indent=2): def printAlignOfType(self, prefix, name, t, output=None, indent=2): print( - '%*sprintf("%s: __alignof__(%s) = %%ld\\n", (long)__alignof__(%s));' + '%*sprintf("%s: alignof(%s) = %%ld\\n", (long)_Alignof(%s));' % (indent, "", prefix, name, name), file=output, ) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
