<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 - Clang 6 fails to compile boost variant code in unnamed namespace"
   href="https://bugs.llvm.org/show_bug.cgi?id=35842">35842</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang 6 fails to compile boost variant code in unnamed namespace
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </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>enhancement
          </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>david@davidhallas.dk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19640" name="attach_19640" title="Simplified test case">attachment 19640</a> <a href="attachment.cgi?id=19640&action=edit" title="Simplified test case">[details]</a></span>
Simplified test case

Clang 6 fails to compile the simple example attached to the bug. It fails with
the following error:

In file included from test.cpp:1:
In file included from /usr/include/boost/variant/variant.hpp:30:
In file included from /usr/include/boost/variant/detail/initializer.hpp:21:
In file included from /usr/include/boost/detail/reference_content.hpp:19:
In file included from /usr/include/boost/type_traits/has_nothrow_copy.hpp:19:
In file included from
/usr/include/boost/type_traits/is_copy_constructible.hpp:17:
In file included from /usr/include/boost/type_traits/is_constructible.hpp:17:
In file included from /usr/include/boost/type_traits/is_destructible.hpp:19:
/usr/include/boost/type_traits/declval.hpp:40:44: error: function
'boost::declval<(anonymous namespace)::Pod &>' is used but not defined in this
translation unit, and cannot be defined in any other translation unit because
its
      type does not have linkage
    typename add_rvalue_reference<T>::type declval() BOOST_NOEXCEPT; // as
unevaluated operand
                                           ^
/usr/include/boost/variant/detail/apply_visitor_unary.hpp:112:30: note: used
here
        return vis()( boost::declval< value_t& >() );
                             ^
1 error generated.

If I move the Pod type out of the unnamed namespace it compiles fine. Also if
the visitor type is, say an int, it also compiles fine.

The same code compiles fine with clang-5 and gcc-6.

I have tested with boost-1.63.0 and boost-1.66.0 but with no difference.

The code is compiled with
clang++ -c test.cpp</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>