<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Unexpected undefined reference to implicitly declared destructor"
   href="https://bugs.llvm.org/show_bug.cgi?id=39808">39808</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unexpected undefined reference to implicitly declared destructor
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>diego.nehab@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21165" name="attach_21165" title="Source code">attachment 21165</a> <a href="attachment.cgi?id=21165&action=edit" title="Source code">[details]</a></span>
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</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>