[LLVMbugs] [Bug 7974] New: extra "field is uninitialized" warning when passing &field to field's ctor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 23 11:07:45 PDT 2010


           Summary: extra "field is uninitialized" warning when passing
                    &field to field's ctor
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: evan at chromium.org
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

Created an attachment (id=5404)
 --> (http://llvm.org/bugs/attachment.cgi?id=5404)
demo code

class Foo {
  Foo() : bar(&bar) {}
  void* bar;

g++ Ubuntu 4.4.3-4ubuntu5 with -Wall -Wextra doesn't complain about this code.

clang++ r111814 says
bug.cc:4:16: warning: field is uninitialized when used here [-Wuninitialized]
  Foo() : bar(&bar) {}

This kind of code *can* be wrong, for example if bar had a ctor that did
something with the pointer passed to it.  But in any case that warning doesn't
really say that.

This pattern occurs in Chrome.
the code looks like:
  LinkedList() : root_(&root_, &root_) {}

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list