[LLVMbugs] [Bug 19793] New: c++1y tuple constructor mistakes arguments for allocator?

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon May 19 10:31:59 PDT 2014


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

            Bug ID: 19793
           Summary: c++1y tuple constructor mistakes arguments for
                    allocator?
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zerolo at gmail.com
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

Created attachment 12541
  --> http://llvm.org/bugs/attachment.cgi?id=12541&action=edit
Example failing using -std=c++1y

The attached code compiles fine with clang using -std=c++11 but fails inside
libc++ when using -std=c++1y.

It seems that a tuple constructor mistakes its argument for an allocator, but
the actual error comes from inside an std::is_convertible check as far as I can
tell.

g++-4.9 compiles the example fine.

> cat test_tuple.cpp 
#include <tuple>

int main (int argc, char const *argv[])
{
  const int i = 5;
  const auto t = std::forward_as_tuple(i, i);
  auto breaks = std::forward_as_tuple(i, t, i, i);
  return 0;
}

> clang++ --std=c++1y test_tuple.cpp 
In file included from test_tuple.cpp:1:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:180:73:
error: reference to type 'const int' requires an initializer
             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
                                                                        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:402:13:
note: in instantiation of member function
      'std::__1::__tuple_leaf<1, const int &, false>::__tuple_leaf' requested
here
            __tuple_leaf<_Ul, _Tl>()...
            ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:552:15:
note: in instantiation of function template specialization
      'std::__1::__tuple_impl<std::__1::__tuple_indices<0, 1>, const int &,
const int &>::__tuple_impl<0, const int &, 1, const int &, const int &>'
requested here
            : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:802:38:
note: in instantiation of function template specialization
      'std::__1::tuple<const int &, const int &>::tuple<const int &, false>'
requested here
    : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__tuple:228:32:
note: in instantiation of template class 'std::__1::is_convertible<const int &,
      const std::__1::tuple<const int &, const int &> &>' requested here
                               is_convertible<_Tp0, _Up0>::value &&
                               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__tuple:229:32:
note: in instantiation of template class
'std::__1::__tuple_convertible_imp<true,
      std::__1::__tuple_types<const int &>, std::__1::__tuple_types<const
std::__1::tuple<const int &, const int &> &> >' requested here
                               __tuple_convertible_imp<true,
__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
                               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__tuple:242:14:
note: in instantiation of template class
'std::__1::__tuple_convertible_imp<true,
      std::__1::__tuple_types<const int &, const int &>,
std::__1::__tuple_types<const int &, const std::__1::tuple<const int &, const
int &> &> >' requested here
    : public __tuple_convertible_imp<tuple_size<typename
remove_reference<_Tp>::type>::value ==
             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:603:26:
note: in instantiation of template class
      'std::__1::__tuple_convertible<std::__1::tuple<const int &, const int &>,
std::__1::__tuple_types<const int &, const std::__1::tuple<const int &, const
int &> &>, true, true>' requested here
                         __tuple_convertible
                         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:614:9:
note: in instantiation of default argument for 'tuple<std::__1::tuple<const int
&,
      const int &>, const int &, const int &>' required here
        tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
        ^~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:614:9:
note: while substituting deduced template arguments into function template
'tuple'
      [with _Alloc = std::__1::tuple<const int &, const int &>, _Up = <const
int &, const int &>, $2 = <no value>]
        tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
        ^
test_tuple.cpp:7:22: note: in instantiation of function template specialization
'std::__1::forward_as_tuple<const int &, const std::__1::tuple<const int &,
const int &> &, const int &, const int &>'
      requested here
  auto breaks = std::forward_as_tuple(i, t, i, i);
                     ^
In file included from test_tuple.cpp:1:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:181:9:
error: static_assert failed
      "Attempted to default construct a reference element in a tuple"
       {static_assert(!is_reference<_Hp>::value,
        ^             ~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

-- 
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/20140519/14dc7da5/attachment.html>


More information about the llvm-bugs mailing list