+2025-05-25 Bruno Haible <bruno@clisp.org>
+
+ stddef-h tests: Add more C++ tests.
+ * tests/test-stddef-h-c++2.cc: Test the expected contents of <cstddef>.
+
2025-05-25 Bruno Haible <bruno@clisp.org>
selinux-h: Fix error with MSVC.
#include <config.h>
#include <cstddef>
+
+/* Test the expected contents of <cstddef>, cf.
+ <https://en.cppreference.com/w/cpp/header/cstddef>. */
+
+/* Check that appropriate types are defined. */
+ptrdiff_t b = 1;
+size_t c = 2;
+
+#if !defined __cplusplus || defined __GNUC__ || defined __clang__
+/* Check that NULL can be passed through varargs as a pointer type,
+ per POSIX 2008. */
+static_assert (sizeof NULL == sizeof (void *));
+#endif
+
+/* Check that offsetof produces integer constants with correct type. */
+struct d
+{
+ char e;
+ char f;
+};
+static_assert (sizeof (offsetof (struct d, e)) == sizeof (size_t));
+static_assert (offsetof (struct d, f) == 1);
+
+#include <limits.h> /* INT_MAX */
+
+/* offsetof promotes to an unsigned integer if and only if sizes do
+ not fit in int. */
+static_assert ((offsetof (struct d, e) < -1) == (INT_MAX < (size_t) -1));