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

            Bug ID: 99919
           Summary: [9/10/11 Regression] bogus -Wmaybe-uninitialized with
                    a _Bool bit-field
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

This is the -Wmaybe-uninitialized subset of pr99918 showing how the failure to
fail _Bool bit-field expressions can cause bogus warnings.  (Like pr99918, this
was most likely caused by r225825.)

$ cat z.c && gcc -O2 -S -Wall z.c
struct B { _Bool i: 1; _Bool j: 1; };

_Bool z;

void g (struct B b)
{
  _Bool x;

  if (b.i)
    b.j = 0;
  else
    {
      b.j = b.i;
      x = b.i;
    }

  if (b.j)
    z = x;
}

z.c: In function ‘g’:
z.c:18:7: warning: ‘x’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   18 |     z = x;
      |     ~~^~~
z.c:7:9: note: ‘x’ was declared here
    7 |   _Bool x;
      |         ^

Reply via email to