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

            Bug ID: 63149
           Summary: can't initialize std::vector<T> from auto-deduced type
                    'const std::initializer_list<T> &'
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: richard-gccbugzilla at metafoo dot co.uk

Reduced testcase:

namespace std {
  template<typename T> struct initializer_list {
    const T *p; unsigned long n;
    initializer_list(const T *p, unsigned long n);
  };
}
struct vector { vector(std::initializer_list<int>); };
void f(vector);
const auto &r = {1, 2, 3};
int main() { f(r); }

GCC rejects-valid here, saying: 

<stdin>:10:15: error: could not convert ‘r’ from ‘const
std::initializer_list<const int>’ to ‘vector’

Replacing

  const auto &r = {1, 2, 3};

with any of

  const std::initializer_list<int> &r = {1, 2, 3};
  auto &&r = {1, 2, 3};
  auto r = {1, 2, 3};

... makes the problem disappear, so it seems that the 'const' from the
reference is somehow getting muddled into the

Reply via email to