https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66338

--- Comment #2 from Pawel Tomulik <ptomulik at meil dot pw.edu.pl> ---
I found this to be related to std::tuple constructors, especially this one:

      template<typename... _UElements, typename = typename
        enable_if<__and_<is_convertible<_UElements,
                                        _Elements>...>::value>::type>
        explicit
        constexpr tuple(_UElements&&... __elements)
        : _Inherited(std::forward<_UElements>(__elements)...) { }


in some circumstances it gets precedence over the copy constructor.. for
example:

/////////////////////////////////////////////////////////////////////////////
#include <tuple>

struct S {
  int i_;

  template<typename T>
  S(T&& i)
  { i_ = i; }

  S() noexcept : i_{0} {};
};

int main()
{
  S const s{};
  std::tuple<S> t1{s};
  std::tuple<S>{t1}; // well... tuple<S> looks like being "convertible" to S
  return 0;
}
////////////////////////////////////////////////////////////////////////////

ptomulik@barakus:$ g++ -Wall -Wextra -Werror -pedantic -g -O0 -std=c++11 -o
test-gcc test.cpp
test.cpp: In instantiation of ‘S::S(T&&) [with T = std::tuple<S>&]’:
/usr/include/c++/4.9/tuple:142:42:   required from ‘constexpr
std::_Head_base<_Idx, _Head, false>::_Head_base(_UHead&&) [with _UHead =
std::tuple<S>&; long unsigned int _Idx = 0ul; _Head = S]’
/usr/include/c++/4.9/tuple:264:38:   required from ‘constexpr
std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(_UHead&&, _UTail&& ...)
[with _UHead = std::tuple<S>&; _UTail = {}; <template-parameter-2-3> = void;
long unsigned int _Idx = 0ul; _Head = S; _Tail = {}]’
/usr/include/c++/4.9/tuple:407:54:   required from ‘constexpr std::tuple<
<template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements =
{std::tuple<S>&}; <template-parameter-2-2> = void; _Elements = {S}]’
test.cpp:17:19:   required from here
test.cpp:8:8: error: cannot convert ‘std::tuple<S>’ to ‘int’ in assignment
   { i_ = i; }


Is it intended?


Anyway, adding explicit to S(T&&) solves the problem...

Reply via email to