[Bug tree-optimization/88835] overly aggressive -Werror=format-overflow for printf since r265648

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Feb 4 15:42:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88835

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |85741

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
The case in comment #2 is entirely dissimilar to the the one in comment #0 so
it would be better deal with under its own bug.

But unless I'm misreading the code in the translation unit, the warning looks
justified:  filename is cleared by the assignment from the result of mfree()
but then used as an argument to log_internal_realm() right after it.  The
function is declared with attribute printf.  I copied the context of the
warning from the translation unit below.  It doesn't seem to correspond to the
code pointed to in the discussion
(https://github.com/systemd/systemd/issues/11369#issuecomment-453044884): the
mfree() call appears after the test for filename being null.  If I'm missing
something please open a new bug for it.

                        filename = path_make_absolute(path, *p);
                        if (!filename)
                                return -
                                       12
                                             ;
                        ...
                        if (r >= 0)
                          break;

                        filename = mfree(filename);

                        if (r == -
                                 13
                                       )
                                ({ int _level = ((
                               7
                               )), _e = ((r)), _realm = (LOG_REALM_SYSTEMD);
(log_get_max_level_realm(_realm) >= 
                               ((
                               _level
                               ) & 0x07)
                               ) ? log_internal_realm(((_realm) << 10 |
(_level)), _e, "../src/core/load-fragment.c", 4301, __func__, "Cannot access
\"%s\": %m", filename) : -abs(_e); });


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85741
[Bug 85741] [meta-bug] bogus/missing -Wformat-overflow


More information about the Gcc-bugs mailing list