[Bug c++/56319] New: call to implicitly-deleted copy constructor accepted

wlodzimierz.lipert at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 14 12:06:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56319

             Bug #: 56319
           Summary: call to implicitly-deleted copy constructor accepted
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: wlodzimierz.lipert@gmail.com


Hi,

GCC compiles following code. Copying of tuple of rvalues returned by:
std::forward_as_tuple, should not be allowed because it is ill formed.
(clang++ properly detects the problem and report an error.)
/*----------------------------------------------------------------------------*/
template <unsigned int ...>
struct TupleIndices
{};

template<
        unsigned int I,
        typename IndexTuple,
        typename... Types>
struct MakeTupleIndices_;

template<
         unsigned int I,
         unsigned int... Indices,
         typename T,
         typename... Types>
struct MakeTupleIndices_<I, TupleIndices<Indices...>, T, Types...>
{
    typedef typename MakeTupleIndices_<I + 1, TupleIndices<Indices..., I>,
Types...>::type type;
};

template<
        unsigned int I,
        unsigned int... Indices>
        struct MakeTupleIndices_<I, TupleIndices<Indices...> >
{
    typedef TupleIndices<Indices...> type;
};

template<typename... Types>
struct MakeTupleIndices : public MakeTupleIndices_<0, TupleIndices<>, Types...>
{};
/*----------------------------------------------------------------------------*/
void bar(int)
{
}

template <typename... Args, unsigned int... ArgsIndices>
void fooImpl(std::tuple<Args...> args, TupleIndices<ArgsIndices...>)
{
        bar(std::forward<Args>(std::get<ArgsIndices>(args))...);
}

template <typename... Args>
void foo(std::tuple<Args...> args)
{
    fooImpl(args, typename MakeTupleIndices<Args...>::type());
}
/*----------------------------------------------------------------------------*/
enum
{
    id = 1
};

int main()
{
    foo(std::forward_as_tuple(id));
    return 0;
}
/*----------------------------------------------------------------------------*/

Wlodzimierz.



More information about the Gcc-bugs mailing list