MSYS2 has an environment for compiling native Windows programs with clang
and the mingw headers and libraries (with UCRT). Unlike the older
clang + MSVC headers combination for which I added support in August 2020,
this port does not define _MSC_VER; rather it defines __GNUC__.

In this environment, I'm seeing a compilation error:

In file included from ../../gltests/test-stddef-h-c++.cc:20:
../../gltests/test-stddef-h.c:34:16: error: static assertion failed due to 
requirement 'sizeof 0 == sizeof(void *)'
   34 | static_assert (sizeof NULL == sizeof (void *));
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gltests/test-stddef-h.c:34:28: note: expression evaluates to '4 == 8'
   34 | static_assert (sizeof NULL == sizeof (void *));
      |                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
1 error generated.
make[4]: *** [Makefile:1793: test-stddef-h-c++.o] Error 1

The definition of NULL comes from the file
/clang64/lib/clang/22/include/__stddef_null.h.

This patch works around it.


2026-09-02  Bruno Haible  <[email protected]>

        stddef-h C++ tests: Avoid compilation error with clang+mingw toolchain.
        * tests/test-stddef-h.c: Skip the 'sizeof NULL' test with clang on
        Windows.
        * tests/test-stddef-h-c++2.cc: Likewise.

diff --git a/tests/test-stddef-h-c++2.cc b/tests/test-stddef-h-c++2.cc
index e476fa221d..662b233fbf 100644
--- a/tests/test-stddef-h-c++2.cc
+++ b/tests/test-stddef-h-c++2.cc
@@ -26,7 +26,7 @@
 ptrdiff_t b2 = 1;
 size_t c2 = 2;
 
-#if !(defined __cplusplus && defined _MSC_VER)
+#if !(defined __cplusplus && defined _WIN32 && (defined __clang__ || defined 
_MSC_VER))
 /* Check that NULL can be passed through varargs as a pointer type,
    per POSIX 2008.  */
 static_assert (sizeof NULL == sizeof (void *));
diff --git a/tests/test-stddef-h.c b/tests/test-stddef-h.c
index 2057c80aac..da46352e54 100644
--- a/tests/test-stddef-h.c
+++ b/tests/test-stddef-h.c
@@ -28,7 +28,7 @@ size_t c = 2;
 max_align_t mat;
 #endif
 
-#if !(defined __cplusplus && defined _MSC_VER)
+#if !(defined __cplusplus && defined _WIN32 && (defined __clang__ || defined 
_MSC_VER))
 /* Check that NULL can be passed through varargs as a pointer type,
    per POSIX 2008.  */
 static_assert (sizeof NULL == sizeof (void *));




Reply via email to