This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: don't warn about uninitialized anonymous bitfields


On 3/7/07, Alexandre Oliva <aoliva@redhat.com> wrote:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=229459

When compiling code such as:

// gcc -O2 -Wall -S uninit-anon-bitfield.c

struct foo {
  unsigned int a:16;
  unsigned int b:11;
  unsigned int :5;
};

extern struct foo bar;

void foo(int a, int b)
{
  struct foo tmp;

  tmp.a = a;
  tmp.b = b;

  bar = tmp;
}

GCC scalarizes tmp and then issues a warning about the use of the
uninitialized annoymous bitfield.

This patch silences the warning.  Bootstrapped and regtested on
x86_64-linux-gnu.   Ok to install?

The middle-end parts are ok with the following change:


      DECL_IGNORED_P (var) = 0;
-
+      TREE_NO_WARNING (var) = TREE_NO_WARNING (base)
+       || (elt->element ? TREE_NO_WARNING (elt->element) : false);
    }

better write that as

 TREE_NO_WARNING (var) = TREE_NO_WARNING (base);
  if (elt->element
      && TREE_NO_WARNING (elt->element))
    TREE_NO_WARNING (var) = 1;

The C and C++ parts need approval from a respective maintainer.

Thanks,
Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]