[Bug tree-optimization/101272] [12 Regression] error: ‘nonnull’ argument ‘message’ compared to NULL [-Werror=nonnull-compare] since r12-1805

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jun 30 15:30:59 GMT 2021


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12 Regression] error:      |[12 Regression] error:
                   |‘nonnull’ argument          |‘nonnull’ argument
                   |‘message’ compared to NULL  |‘message’ compared to NULL
                   |[-Werror=nonnull-compare]   |[-Werror=nonnull-compare]
                   |since                       |since r12-1805
           Keywords|                            |diagnostic

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning is valid and expected.  It started to be issued with r12-1805. 
Prior to that, the parentheses around the inequality expression suppressed it,
like so:

$ cat t.C && cc1plus.r12-1804 -quiet -Wall -Werror -o/dev/null t.C
__attribute__ ((nonnull)) void
f (int *p) { p == 0 ? __builtin_abort () : (void)0; }

__attribute__ ((nonnull)) void
g (int *p) { (p == 0) ? __builtin_abort () : (void)0; }

t.C: In function ‘void f(int*)’:
t.C:2:21: error: ‘nonnull’ argument ‘p’ compared to NULL
[-Werror=nonnull-compare]
    2 | f (int *p) { p == 0 ? __builtin_abort () : (void)0; }
      |              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus.r12-1804: all warnings being treated as errors


More information about the Gcc-bugs mailing list