[llvm-bugs] [Bug 28280] New: Undefined reference to destructor in some cases

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 23 06:04:11 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28280

            Bug ID: 28280
           Summary: Undefined reference to destructor in some cases
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: burchakov.oleg at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

$ cat test.cc
struct Buzz
{
    ~Buzz() {};
};

struct Foo
{
    Buzz buzz;
};

struct Bar
{
    static Bar create() { return Bar(); };
};

struct FooBar
{
    Foo foo;
    Bar bar;

    static FooBar read(const Foo& foo);
};

FooBar FooBar::read(const Foo& foo)
{
    return
    {
        foo,
        Bar::create()
    };
}

int main()
{
    FooBar::read(Foo());
}

$ ./clang++ -std=c++11 -O0 test.cc
/tmp/test-034a8e.o: In function `FooBar::read(Foo const&)':
test.cc:(.text+0x40): undefined reference to `Foo::~Foo()'
/tmp/test-034a8e.o: In function `main':
test.cc:(.text+0x9c): undefined reference to `Foo::~Foo()'
test.cc:(.text+0xb6): undefined reference to `Foo::~Foo()'
/tmp/test-034a8e.o: In function `FooBar::~FooBar()':
test.cc:(.text._ZN6FooBarD2Ev[_ZN6FooBarD2Ev]+0x11): undefined reference to
`Foo::~Foo()'
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160623/d84df9f0/attachment.html>


More information about the llvm-bugs mailing list