[llvm-bugs] [Bug 32639] New: Invalid error "exception specification of 'XXX' uses itself"

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 12 09:14:58 PDT 2017


http://bugs.llvm.org/show_bug.cgi?id=32639

            Bug ID: 32639
           Summary: Invalid error "exception specification of 'XXX' uses
                    itself"
           Product: clang
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: officesamurai at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Created attachment 18275
  --> http://bugs.llvm.org/attachment.cgi?id=18275&action=edit
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.

-- 
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/20170412/84b3b0f7/attachment.html>


More information about the llvm-bugs mailing list