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

            Bug ID: 117610
           Summary: -Wzero-as-null-pointer-constant false positive with
                    {0}
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alx at kernel dot org
  Target Milestone: ---

Reproducer:

alx@debian:~/tmp/gcc$ cat wzanpc.c 
struct s1 {
        int  x;
};
struct s2 {
        int  *x;
};

int
main(void)
{
        struct s1  a1[42] = {0};
        struct s2  a2[42] = {0};
}
alx@debian:~/tmp/gcc$ gcc -Wzero-as-null-pointer-constant wzanpc.c 
wzanpc.c: In function ‘main’:
wzanpc.c:12:30: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
   12 |         struct s2  a2[42] = {0};
      |                              ^


The 0 is not initializing the struct member .x, but the array element --which
is a structure--, so it's not being used as a pointer.

Reply via email to