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

             Bug #: 53361
           Summary: Could not convert ‘{0, 0, 0}’ from ‘<brace-enclosed
                    initializer list>’ to ‘std::array<unsigned int, 3ul>’
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: roucaries.bastien+b...@gmail.com


Fail to compile:

#include <array>

void function(std::array<unsigned int,3> a)
{
}

int main()
{
    // ok
  std::array<unsigned int,3> vec {0, 0, 0};

    // error: could not convert '{"hello", "world", "test"}' to
'std::vector...'
  function({0,0,0});
}

--------------------
8.5/14,16:

    The initialization that occurs in the form

    T x = a;

    as well as in argument passing, function return, throwing an exception
(15.1), handling an exception (15.3), and aggregate member initialization
(8.5.1) is called copy-initialization.
    .
    .
    The semantics of initializers are as follows[...]: If the initializer is a
braced-init-list, the object is list-initialized (8.5.4).

So it seems a bug.

bastien

Reply via email to