This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/53361] New: Could not convert â{0, 0, 0}â from â<brace-enclosed initializer list>â to âstd::array<unsigned int, 3ul>â


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: unassigned@gcc.gnu.org
        ReportedBy: roucaries.bastien+bugs@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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]