Static assertion on atomic operations fails on 64bit Windows
While trying to compile Gnome Text Editor on Windows in the Msys2 environment I came across the following error:
[889/3561] Compiling C object subprojects/glib/gio/tests/cancellable.exe.p/cancellable.c.obj
FAILED: subprojects/glib/gio/tests/cancellable.exe.p/cancellable.c.obj
"cc" "-Isubprojects/glib/gio/tests/cancellable.exe.p" "-Isubprojects/glib/gio/tests" "-I../subprojects/glib/gio/tests" "-Isubprojects/glib" "-I../subprojects/glib" "-Isubprojects/glib/glib" "-I../subprojects/glib/glib" "-Isubprojects/glib/gmodule" "-I../subprojects/glib/gmodule" "-Isubprojects/glib/gobject" "-I../subprojects/glib/gobject" "-Isubprojects/glib/gio" "-I../subprojects/glib/gio" "-fdiagnostics-color=always" "-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-Wextra" "-Wpedantic" "-std=gnu99" "-O0" "-g" "-D_GNU_SOURCE" "-fno-strict-aliasing" "-DG_ENABLE_DEBUG" "-Wduplicated-branches" "-Wimplicit-fallthrough" "-Wmisleading-indentation" "-Wunused" "-Wno-unused-parameter" "-Wno-cast-function-type" "-Wno-pedantic" "-Wno-format-zero-length" "-Wno-variadic-macros" "-Werror=format=2" "-Werror=init-self" "-Werror=missing-include-dirs" "-Werror=pointer-arith" "-Werror=unused-result" "-Wstrict-prototypes" "-Wno-bad-function-cast" "-Werror=declaration-after-statement" "-Werror=implicit-function-declaration" "-Werror=missing-prototypes" "-Werror=pointer-sign" "-mms-bitfields" "-DG_LOG_DOMAIN=\"GLib-GIO\"" "-DGLIB_MKENUMS=\"subprojects/glib/gobject/glib-mkenums\"" "-DGLIB_COMPILE_SCHEMAS=\"C:/Users/Zachary/Desktop/reproduce-errors-8/gnome-text-editor/builddir/subprojects/glib/gio/glib-compile-schemas.exe\"" "-UG_DISABLE_ASSERT" -MD -MQ subprojects/glib/gio/tests/cancellable.exe.p/cancellable.c.obj -MF "subprojects/glib/gio/tests/cancellable.exe.p/cancellable.c.obj.d" -o subprojects/glib/gio/tests/cancellable.exe.p/cancellable.c.obj "-c" ../subprojects/glib/gio/tests/cancellable.c
In file included from subprojects/glib/glib/glibconfig.h:9,
from ../subprojects/glib/glib/gtypes.h:34,
from ../subprojects/glib/glib/galloca.h:34,
from ../subprojects/glib/glib/glib.h:32,
from ../subprojects/glib/gobject/gbinding.h:30,
from ../subprojects/glib/glib/glib-object.h:24,
from ../subprojects/glib/gio/gioenums.h:30,
from ../subprojects/glib/gio/giotypes.h:30,
from ../subprojects/glib/gio/gio.h:28,
from ../subprojects/glib/gio/tests/cancellable.c:25:
../subprojects/glib/gio/tests/cancellable.c: In function 'on_cancellable_connect_disconnect':
../subprojects/glib/glib/gmacros.h:831:53: error: size of array '_GStaticAssertCompileTimeAssertion_6' is negative
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:820:47: note: in definition of macro 'G_PASTE_ARGS'
820 | #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
| ^~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:44: note: in expansion of macro 'G_PASTE'
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~
../subprojects/glib/glib/gatomic.h:273:5: note: in expansion of macro 'G_STATIC_ASSERT'
273 | G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
| ^~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c:478:32: note: in expansion of macro 'g_atomic_pointer_exchange'
478 | gulong handler_id = (gulong) g_atomic_pointer_exchange (&data->handler_id, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../subprojects/glib/glib/gthread.h:34,
from ../subprojects/glib/glib/gasyncqueue.h:34,
from ../subprojects/glib/glib/glib.h:34:
../subprojects/glib/glib/gatomic.h:274:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
274 | (void) (0 ? (gpointer) *(atomic) : NULL); \
| ^
../subprojects/glib/gio/tests/cancellable.c:478:32: note: in expansion of macro 'g_atomic_pointer_exchange'
478 | gulong handler_id = (gulong) g_atomic_pointer_exchange (&data->handler_id, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gatomic.h:275:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
275 | (gpointer) __atomic_exchange_n ((atomic), (newval), __ATOMIC_SEQ_CST); \
| ^
../subprojects/glib/gio/tests/cancellable.c:478:32: note: in expansion of macro 'g_atomic_pointer_exchange'
478 | gulong handler_id = (gulong) g_atomic_pointer_exchange (&data->handler_id, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c:478:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
478 | gulong handler_id = (gulong) g_atomic_pointer_exchange (&data->handler_id, 0);
| ^
../subprojects/glib/gio/tests/cancellable.c: In function 'connecting_thread':
../subprojects/glib/glib/gmacros.h:831:53: error: size of array '_GStaticAssertCompileTimeAssertion_9' is negative
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:820:47: note: in definition of macro 'G_PASTE_ARGS'
820 | #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
| ^~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:44: note: in expansion of macro 'G_PASTE'
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~
../subprojects/glib/glib/gatomic.h:136:5: note: in expansion of macro 'G_STATIC_ASSERT'
136 | G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
| ^~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c:499:3: note: in expansion of macro 'g_atomic_pointer_set'
499 | g_atomic_pointer_set (&data->handler_id, handler_id);
| ^~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gatomic.h:139:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
139 | (void) (0 ? (gpointer) * (atomic) : NULL); \
| ^
../subprojects/glib/gio/tests/cancellable.c:499:3: note: in expansion of macro 'g_atomic_pointer_set'
499 | g_atomic_pointer_set (&data->handler_id, handler_id);
| ^~~~~~~~~~~~~~~~~~~~
In file included from ../subprojects/glib/glib/glib.h:88:
../subprojects/glib/gio/tests/cancellable.c: In function 'test_cancellable_disconnect_on_cancelled_callback_hangs':
../subprojects/glib/glib/gmacros.h:831:53: error: size of array '_GStaticAssertCompileTimeAssertion_12' is negative
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gtestutils.h:59:62: note: in definition of macro 'g_assert_cmpuint'
59 | guint64 __n1 = (n1), __n2 = (n2); \
| ^~
../subprojects/glib/glib/gmacros.h:821:47: note: in expansion of macro 'G_PASTE_ARGS'
821 | #define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
| ^~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:44: note: in expansion of macro 'G_PASTE'
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~
../subprojects/glib/glib/gatomic.h:128:5: note: in expansion of macro 'G_STATIC_ASSERT'
128 | G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
| ^~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c:540:30: note: in expansion of macro 'g_atomic_pointer_get'
540 | g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), ==, 0);
| ^~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:53: error: size of array '_GStaticAssertCompileTimeAssertion_14' is negative
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gtestutils.h:59:62: note: in definition of macro 'g_assert_cmpuint'
59 | guint64 __n1 = (n1), __n2 = (n2); \
| ^~
../subprojects/glib/glib/gmacros.h:821:47: note: in expansion of macro 'G_PASTE_ARGS'
821 | #define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
| ^~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:44: note: in expansion of macro 'G_PASTE'
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~
../subprojects/glib/glib/gatomic.h:128:5: note: in expansion of macro 'G_STATIC_ASSERT'
128 | G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
| ^~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c:549:30: note: in expansion of macro 'g_atomic_pointer_get'
549 | g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), !=, 0);
| ^~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:53: error: size of array '_GStaticAssertCompileTimeAssertion_17' is negative
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gtestutils.h:59:62: note: in definition of macro 'g_assert_cmpuint'
59 | guint64 __n1 = (n1), __n2 = (n2); \
| ^~
../subprojects/glib/glib/gmacros.h:821:47: note: in expansion of macro 'G_PASTE_ARGS'
821 | #define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
| ^~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:44: note: in expansion of macro 'G_PASTE'
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~
../subprojects/glib/glib/gatomic.h:128:5: note: in expansion of macro 'G_STATIC_ASSERT'
128 | G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
| ^~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c:565:30: note: in expansion of macro 'g_atomic_pointer_get'
565 | g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), ==, 0);
| ^~~~~~~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c: In function 'test_cancellable_reset_on_cancelled_callback_hangs':
../subprojects/glib/glib/gmacros.h:831:53: error: size of array '_GStaticAssertCompileTimeAssertion_23' is negative
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gtestutils.h:59:62: note: in definition of macro 'g_assert_cmpuint'
59 | guint64 __n1 = (n1), __n2 = (n2); \
| ^~
../subprojects/glib/glib/gmacros.h:821:47: note: in expansion of macro 'G_PASTE_ARGS'
821 | #define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
| ^~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:44: note: in expansion of macro 'G_PASTE'
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~
../subprojects/glib/glib/gatomic.h:128:5: note: in expansion of macro 'G_STATIC_ASSERT'
128 | G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
| ^~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c:625:30: note: in expansion of macro 'g_atomic_pointer_get'
625 | g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), ==, 0);
| ^~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:53: error: size of array '_GStaticAssertCompileTimeAssertion_25' is negative
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gtestutils.h:59:62: note: in definition of macro 'g_assert_cmpuint'
59 | guint64 __n1 = (n1), __n2 = (n2); \
| ^~
../subprojects/glib/glib/gmacros.h:821:47: note: in expansion of macro 'G_PASTE_ARGS'
821 | #define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
| ^~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:44: note: in expansion of macro 'G_PASTE'
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~
../subprojects/glib/glib/gatomic.h:128:5: note: in expansion of macro 'G_STATIC_ASSERT'
128 | G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
| ^~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c:634:30: note: in expansion of macro 'g_atomic_pointer_get'
634 | g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), !=, 0);
| ^~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:53: error: size of array '_GStaticAssertCompileTimeAssertion_28' is negative
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../subprojects/glib/glib/gtestutils.h:59:62: note: in definition of macro 'g_assert_cmpuint'
59 | guint64 __n1 = (n1), __n2 = (n2); \
| ^~
../subprojects/glib/glib/gmacros.h:821:47: note: in expansion of macro 'G_PASTE_ARGS'
821 | #define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
| ^~~~~~~~~~~~
../subprojects/glib/glib/gmacros.h:831:44: note: in expansion of macro 'G_PASTE'
831 | #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
| ^~~~~~~
../subprojects/glib/glib/gatomic.h:128:5: note: in expansion of macro 'G_STATIC_ASSERT'
128 | G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
| ^~~~~~~~~~~~~~~
../subprojects/glib/gio/tests/cancellable.c:650:30: note: in expansion of macro 'g_atomic_pointer_get'
650 | g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), >, 0);
| ^~~~~~~~~~~~~~~~~~~~
[890/3561] Compiling C object subprojects/glib/gio/tests/contenttype.exe.p/contenttype.c.obj
[891/3561] Compiling C object subprojects/glib/gio/tests/contexts.exe.p/contexts.c.obj
[892/3561] Compiling C object subprojects/glib/gio/tests/converter-stream.exe.p/converter-stream.c.obj
[893/3561] Compiling C object subprojects/glib/gio/tests/credentials.exe.p/credentials.c.obj
[894/3561] Generating symbol file subprojects/glib/gio/libgio-2.0-0.dll.p/libgio-2.0-0.dll.symbols
ninja: build stopped: subcommand failed.
The error can be reproduced with the following (you might need to install and set paths for dependencies of Gnome Text Editor if they aren't already installed, don't worry if this happens):
git clone https://gitlab.gnome.org/GNOME/gnome-text-editor.git
cd gnome-text-editor
meson setup builddir/ -Dforce_fallback_for=libadwaita && meson compile -C builddir/
If you get any dependency errors just run the following and try running the meson command again (copied from my pipeline):
yes | pacman -S mingw-w64-x86_64-pkg-config
yes | pacman -S pkg-config
yes | pacman -S mingw-w64-x86_64-gstreamer
yes | pacman -S mingw-w64-x86_64-gst-plugins-base
yes | pacman -S mingw-w64-x86_64-gst-plugins-bad
yes | pacman -S mingw-w64-x86_64-gst-plugins-good
yes | pacman -S mingw-w64-x86_64-gst-plugins-ugly
yes | pacman -S mingw-w64-x86_64-gst-plugins-bad-libs
yes | pacman -S mingw-w64-x86_64-gtk4
yes | pacman -S mingw-w64-x86_64-meson
yes | pacman -S mingw-w64-x86_64-libadwaita
yes | pacman -S mingw-w64-x86_64-gobject-introspection
yes | pacman -S mingw-w64-x86_64-python-gobject
yes | pacman -S mingw-w64-x86_64-vala
yes | pacman -S mingw-w64-x86_64-enchant
yes | pacman -S mingw-w64-clang-x86_64-itstool
yes | pacman -S itstool
echo "all" | pacman -S --needed base-devel mingw-w64-x86_64-toolchain
Attached are the meson logs and the ninja build files: meson-log.txtbuild.ninja
Edited by Christoph Reiter