Open
Bug 1710120
Opened 4 years ago
Updated 2 years ago
Glib macros such as `g_clear_pointer` trigger "WARNING: suspicious usage of 'sizeof(A*)';"
Categories
(Developer Infrastructure :: Source Code Analysis, defect, P3)
Tracking
(Not tracked)
NEW
People
(Reporter: rmader, Unassigned)
References
Details
g_clear_pointer
[1] and friends are very common in GTK/GLib code and are encouraged to be used to safely clean pointers. Right now, they trigger warnings, either when used in new code[2] or when touching any file containing them[3], such as:
0:40.25 /home/robert/firefox/gecko-dev/widget/gtk/MozContainerWayland.cpp
0:40.25 Warning: bugprone-sizeof-expression in widget/gtk/MozContainerWayland.cpp: suspicious usage of 'sizeof(A*)'; pointer to aggregate
0:40.25 [1m/home/robert/firefox/gecko-dev/widget/gtk/MozContainerWayland.cpp:205:3: [0m[0;1;35mwarning: [0m[1msuspicious usage of 'sizeof(A*)'; pointer to aggregate [bugprone-sizeof-expression][0m
0:40.25 g_clear_pointer(&wl_container->frame_callback_handler, wl_callback_destroy);
0:40.25 [0;1;32m ^
0:40.25 [0m[1m/usr/include/glib-2.0/glib/gmem.h:134:22: [0m[0;1;30mnote: [0mexpanded from macro 'g_clear_pointer'[0m
0:40.25 G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
0:40.25 [0;1;32m ^
0:40.25 Warning: cppcoreguidelines-pro-type-member-init in widget/gtk/MozContainerWayland.cpp: uninitialized record type: '_pp'
0:40.25 [0m[1m/home/robert/firefox/gecko-dev/widget/gtk/MozContainerWayland.cpp:205:3: [0m[0;1;35mwarning: [0m[1muninitialized record type: '_pp' [cppcoreguidelines-pro-type-member-init][0m
0:40.25 g_clear_pointer(&wl_container->frame_callback_handler, wl_callback_destroy);
0:40.25 [0;1;32m ^
0:40.25 [0m[1m/usr/include/glib-2.0/glib/gmem.h:136:5: [0m[0;1;30mnote: [0mexpanded from macro 'g_clear_pointer'[0m
0:40.25 union { char *in; gpointer *out; } _pp; \
0:40.25 [0;1;32m ^
It would be great if this could somehow get silenced, as it appears to make some reviewers reluctant to merge code with lots of warnings, even if they are completely harmless.
1: https://gitlab.gnome.org/GNOME/glib/-/blob/master/glib/gmem.h#L118-150
2: https://phabricator.services.mozilla.com/D114349
3: https://phabricator.services.mozilla.com/D111662#3697857
Updated•2 years ago
|
Product: Firefox Build System → Developer Infrastructure
You need to log in
before you can comment on or make changes to this bug.
Description
•