diff --git a/subprojects/libglnx/tests/libglnx-testlib.h b/subprojects/libglnx/tests/libglnx-testlib.h
index 0d3a07511f428a6ca3d9584ee36af1b2091dc6a6..d45ba8602187831f8900510c0dddcb144bfc2e61 100644
--- a/subprojects/libglnx/tests/libglnx-testlib.h
+++ b/subprojects/libglnx/tests/libglnx-testlib.h
@@ -45,4 +45,4 @@ void _glnx_test_auto_temp_dir_leave (_GLnxTestAutoTempDir *dir);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(_GLnxTestAutoTempDir, _glnx_test_auto_temp_dir_leave);
 
 #define _GLNX_TEST_SCOPED_TEMP_DIR \
-  g_autoptr(_GLnxTestAutoTempDir) temp_dir = _glnx_test_auto_temp_dir_enter ()
+  G_GNUC_UNUSED g_autoptr(_GLnxTestAutoTempDir) temp_dir = _glnx_test_auto_temp_dir_enter ()