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

Aidan MacDonald <amachronic at protonmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amachronic at protonmail dot 
com

--- Comment #9 from Aidan MacDonald <amachronic at protonmail dot com> ---
I am also hitting this with GCC 12.2. One more detail to add is that the info
manual says the -Waddress warning should be suppressed if it's a result of a
macro expansion. This does indeed happen when the macro is the only thing in
the conditional, but not when the macro is part of a larger expression.

Example (https://godbolt.org/z/YEY4Yzdnf):

    #include <stddef.h>

    #define MACRO(buf, off) (off < 0 ? NULL : (void*)&buf[off])

    void func(char *buf, long off)
    {
        if (off < 0 ? NULL : (void*)&buf[off]) { } // warning (correct)
        if (!(off < 0 ? NULL : (void*)&buf[off])) { } // warning (correct)
        if (MACRO(buf, off)) { } // no warning (correct)
        if (!MACRO(buf, off)) { } // gives a false positive -Waddress
    }

Reply via email to