<html>
    <head>
      <base href="http://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 - Invalid error "exception specification of 'XXX' uses itself""
   href="http://bugs.llvm.org/show_bug.cgi?id=32639">32639</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid error "exception specification of 'XXX' uses itself"
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>4.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>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>officesamurai@gmail.com
          </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=18275" name="attach_18275" title="test code (also in the text)">attachment 18275</a> <a href="attachment.cgi?id=18275&action=edit" title="test code (also in the text)">[details]</a></span>
test code (also in the text)

Compiling a seemingly innocent piece of code produces the error "exception
specification of 'XXX' uses itself".

test.cpp (also attached):

#include <type_traits>

template <typename T>
struct XXX
{
    XXX() {}
    XXX (XXX&&) noexcept(std::is_nothrow_move_constructible<T>::value) {}
};

struct S
{
    S(XXX<int> = XXX<int>()) {}
    S(S&&) noexcept = default;

    XXX<int> x;
};

int main()
{
}

The command line:

~/tmp$ clang++-4.0 test.cpp  -std=c++11 -stdlib=libc++ -o test

The result:

test.cpp:15:14: error: exception specification of 'XXX' uses itself
    XXX<int> x;
             ^
test.cpp:15:14: note: in instantiation of exception specification for 'XXX'
requested here
/home/brd/soft/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/../include/c++/v1/type_traits:1017:6:
note: in instantiation of template class 'std::__1::is_same<int &,
std::__1::__two>' requested here
    !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value>
{};
     ^
/home/brd/soft/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/../include/c++/v1/type_traits:1089:29:
note: in instantiation of template class 'std::__1::__is_referenceable<int>'
requested here
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct
__add_rvalue_reference_impl            { typedef _Tp   type; };
                            ^
/home/brd/soft/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/../include/c++/v1/type_traits:1093:19:
note: in instantiation of default argument for
'__add_rvalue_reference_impl<int>' required here
{typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/brd/soft/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/../include/c++/v1/type_traits:3722:53:
note: in instantiation of template class 'std::__1::add_rvalue_reference<int>'
requested here
    : public is_nothrow_constructible<_Tp, typename
add_rvalue_reference<_Tp>::type>
                                                    ^
test.cpp:7:31: note: in instantiation of template class
'std::__1::is_nothrow_move_constructible<int>' requested here
    XXX (XXX&&) noexcept(std::is_nothrow_move_constructible<T>::value) {}
                              ^
test.cpp:12:16: note: in instantiation of exception specification for 'XXX'
requested here
    S(XXX<int> = XXX<int>()) {}
               ^
test.cpp:13:5: error: exception specification of explicitly defaulted move
constructor does not match the calculated one
    S(S&&) noexcept = default;
    ^
/home/brd/soft/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/../include/c++/v1/type_traits:1017:6:
note: in instantiation of template class 'std::__1::is_same<int &,
std::__1::__two>' requested here
    !is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value>
{};
     ^
/home/brd/soft/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/../include/c++/v1/type_traits:1089:29:
note: in instantiation of template class 'std::__1::__is_referenceable<int>'
requested here
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct
__add_rvalue_reference_impl            { typedef _Tp   type; };
                            ^
/home/brd/soft/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/../include/c++/v1/type_traits:1093:19:
note: in instantiation of default argument for
'__add_rvalue_reference_impl<int>' required here
{typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/brd/soft/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/../include/c++/v1/type_traits:3722:53:
note: in instantiation of template class 'std::__1::add_rvalue_reference<int>'
requested here
    : public is_nothrow_constructible<_Tp, typename
add_rvalue_reference<_Tp>::type>
                                                    ^
test.cpp:7:31: note: in instantiation of template class
'std::__1::is_nothrow_move_constructible<int>' requested here
    XXX (XXX&&) noexcept(std::is_nothrow_move_constructible<T>::value) {}
                              ^
test.cpp:12:16: note: in instantiation of exception specification for 'XXX'
requested here
    S(XXX<int> = XXX<int>()) {}
               ^
2 errors generated.


P.S. clang 3.9.1 is able to compile the code.</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>