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

            Bug ID: 88645
           Summary: Don't assume functions are always nonnull if there's
                    __attribute__((weak_import)), similar to
                    __attribute__((weak))
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mcccs at gmx dot com
  Target Milestone: ---

OS: Darwin/macOS

Test vector:

extern void a (void) __attribute__((weak_import));

int main(void) {
    return !!a;
}

It shouldn't print a warning **iff** on macOS.

This warning:

warning: the address of 'void a()' will never be NULL [-Waddress]

The test would pass if it was __attribute__((weak)) instead of
__attribute__((weak_import))

The fix can be added to the `warn_for_null_address` function in gcc/cp/typeck.c

Aside from the warning, the assembly generation behavior is correct.

Reply via email to