From a9bdb63bba8a631cd4797393307eecf5fcde9167 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sun, 25 Jan 2026 11:16:58 +0100 Subject: [PATCH] Work around buggy alignas in older g++ Older g++ (<9.3) mishandle the alignas specifier (raise warnings that the alignment is too large), but the more or less equivalent attribute works. So as a workaround, #define alignas to that attribute for those versions. see Reviewed-by: Tom Lane Discussion: https://www.postgresql.org/message-id/3119480.1769189606%40sss.pgh.pa.us --- src/include/c.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/include/c.h b/src/include/c.h index c0be07a4566..17afaef9a6a 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -262,6 +262,16 @@ */ #endif +/* + * alignas is buggy in g++ < 9, but the more or less equivalent attribute + * works. + * + * + */ +#if defined(__cplusplus) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 9 +#define alignas(a) __attribute__((aligned(a))) +#endif + /* * Use "pg_attribute_always_inline" in place of "inline" for functions that * we wish to force inlining of, even when the compiler's heuristics would -- 2.39.5