gcc-12.0.1-0.8.fc36 gives wrong dangling-pointer warnings (with unreachable code `for(;;)`). This can be seen when building NetworkManager: Run `podman run -it --privileged fedora:36` Then: ``` dnf upgrade -y dnf install git -y git clone https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git/ cd NetworkManager git checkout -B test 47ff99515f0ecbc791851f3c1a1c61fb7efc234c ./contrib/fedora/REQUIRED_PACKAGES CFLAGS='-O2' ./autogen.sh make src/libnm-glib-aux/libnm_glib_aux_la-nm-shared-utils.lo ``` Compiler failure: ``` In file included from /usr/include/glib-2.0/glib.h:62, from ./src/libnm-glib-aux/nm-default-glib.h:18, from ./src/libnm-glib-aux/nm-default-glib-i18n-lib.h:13, from src/libnm-glib-aux/nm-shared-utils.c:6: src/libnm-glib-aux/nm-shared-utils.c: In function ‘nm_utils_parse_inaddr_bin_full’: src/libnm-glib-aux/nm-shared-utils.c:1145:26: error: dangling pointer to ‘error’ may be used [-Werror=dangling-pointer=] 1145 | error->message); | ^~ /usr/include/glib-2.0/glib/gmessages.h:343:32: note: in definition of macro ‘g_error’ 343 | __VA_ARGS__); \ | ^~~~~~~~~~~ src/libnm-glib-aux/nm-shared-utils.c:1133:31: note: ‘error’ declared here 1133 | gs_free_error GError *error = NULL; | ^~~~~ /usr/include/glib-2.0/glib/gmessages.h:341:25: error: dangling pointer to ‘addrbin’ may be used [-Werror=dangling-pointer=] 341 | g_log (G_LOG_DOMAIN, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 342 | G_LOG_LEVEL_ERROR, \ | ~~~~~~~~~~~~~~~~~~~~~~~ 343 | __VA_ARGS__); \ | ~~~~~~~~~~~~ src/libnm-glib-aux/nm-shared-utils.c:1141:13: note: in expansion of macro ‘g_error’ 1141 | g_error("unexpected assertion failure: could parse \"%s\" as %s, but not accepted by " | ^~~~~~~ src/libnm-glib-aux/nm-shared-utils.c:1112:14: note: ‘addrbin’ declared here 1112 | NMIPAddr addrbin; | ^~~~~~~ cc1: all warnings being treated as errors ``` which happens here: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/47ff99515f0ecbc791851f3c1a1c61fb7efc234c/src/libnm-glib-aux/nm-shared-utils.c#L1141 There are several other failures. Just type `make` in above reproducer. They are related to glib's `g_error()` macro, which is defined here: https://gitlab.gnome.org/GNOME/glib/-/blob/60e8b48be9f2c1cc3f8212ebfaee58f0750a2754/glib/gmessages.h#L344 ``` #define g_error(...) G_STMT_START { \ g_log (G_LOG_DOMAIN, \ G_LOG_LEVEL_ERROR, \ __VA_ARGS__); \ for (;;) ; \ } G_STMT_END ``` The `for(;;)` trips gcc up.
it seems easy to reproduce. Just build upstream glib. Most calls of `g_error()` don't trigger the problem, but many do.
We need either a test case or a preprocessing translation unit and the full GCC command line to reproduce the problem. You can obtain a preprocessing translation unit by compiling the affected source file with the -E option and saving the output to a file. Please attach this file to the report.
gcc-12.0.1-0.12.fc37 in rawhide should fix this, f36 version still building...
FEDORA-2022-9fb66de66d has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-9fb66de66d
FEDORA-2022-42ea499a7d has been pushed to the Fedora 36 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-42ea499a7d` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-42ea499a7d See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.
FEDORA-2022-42ea499a7d has been pushed to the Fedora 36 stable repository. If problem still persists, please make note of it in this bug report.