[llvm-bugs] [Bug 39808] New: Unexpected undefined reference to implicitly declared destructor

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 27 10:18:11 PST 2018


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

            Bug ID: 39808
           Summary: Unexpected undefined reference to implicitly declared
                    destructor
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: diego.nehab at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Created attachment 21165
  --> https://bugs.llvm.org/attachment.cgi?id=21165&action=edit
Source code

Dear all,

When compiling the program below (which was stripped down to its bare mininum)

    #include <boost/container/static_vector.hpp>

    // Comment either of the lines marked as 1, 2, or 3 to make
    // the problem go away
    // Alternatively, uncomment line marked as 4 to make the
    // problem go away

    struct B final {
        B(void) { ; } // 1
    };

    struct A {
        boost::container::static_vector<B, 32> vec; // 2
        B elem; // 3
        // ~A() {} // 4
    };

    A *init(void) {
        return new A{};
    }

    void end(A *a) {
        delete a;
    }

    int main(void) {
        end(init());
        return 0;
    }

The result is an unexpected undefined reference to an implicitly declared
destructor:

    clang++ -O0 -std=c++11 -I/opt/local/include -o a a.cpp
    /tmp/a-31ee39.o: In function `init()':
    a.cpp:(.text+0x62): undefined reference to
`boost::container::static_vector<B, 32ul>::~static_vector()'
    /tmp/a-31ee39.o: In function `A::~A()':
    a.cpp:(.text._ZN1AD2Ev[_ZN1AD2Ev]+0x11): undefined reference to 
    `boost::container::static_vector<B, 32ul>::~static_vector()'
    clang: error: linker command failed with exit code 1 (use -v to see
invocation)

I am no C++ Jedi, but I can't understand why this would be the case. I am even
more confused as to why commenting or uncommenting the lines as marked can
eliminate the issue. For what is worth, g++ 7.3.0 has no problem compiling this
code, whereas clang-6 and clang-7 show the same odd behavior. There is nothing
special with boost either, as I tried several versions. The one I am currently
using is 1.65.1.

If this behavior is expected, I'd be very happy if somebody could clarify this
to me.

Kind regards,
Diego

-- 
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/20181127/1cb8ebf9/attachment.html>


More information about the llvm-bugs mailing list