mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 03:02:10 +01:00
Avoid C++20 deprecated assignment to volatile
794c1a30bc27b4c8d77537813acb1213d5ac80f2 "macro wrappers for g_once_init_enter/leave" added this line (whose intent is unclear to me). <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1152r4.html> "Deprecating volatile" (scheduled for inclusion in C++20) will make the assignment expression *(location) = (result) deprecated when the LHS is of (non-class) volatile type, which is the case when g_once_init_leave is expanded as part of e.g. G_DEFINE_TYPE_WITH_CODE (in gobject/gtype.h), where location is a pointer to some static volatile gsize g_define_type_id__volatile = 0; Recent Clang trunk emits -Wdeprecated-volatile for it under -std=c++2a since <https://github.com/llvm/llvm-project/commit/ 4a6861a7e5b59be24a09b8b9782255d028e7aade> "[c++20] P1152R4: warn on any simple-assignment to a volatile lvalue". The fix is to make the assignment expression a discared-value expression by casting it to void (which in turn requires casting the second branch of the surrounding conditional expression to void, too; not sure what the top-level cast to void was intended for, and whether it would still be needed under certain circumstances).
This commit is contained in:
parent
b3328d77c1
commit
3e4bca79ff
@ -254,7 +254,7 @@ void g_once_init_leave (volatile void *location,
|
||||
# define g_once_init_leave(location, result) \
|
||||
(G_GNUC_EXTENSION ({ \
|
||||
G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \
|
||||
(void) (0 ? *(location) = (result) : 0); \
|
||||
0 ? (void) (*(location) = (result)) : (void) 0; \
|
||||
g_once_init_leave ((location), (gsize) (result)); \
|
||||
}))
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user