[Bug c++/56418] New: <brace-enclosed initializer list> errors do not show the types (makes it hard to debug)

msclrhd at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 21 13:32:00 GMT 2013


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

             Bug #: 56418
           Summary: <brace-enclosed initializer list> errors do not show
                    the types (makes it hard to debug)
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: msclrhd@gmail.com


Created attachment 29518
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29518
Example of the problem.

When you have something like:

    foo({ 1, 2, 3 });

vs:

    foo(Bar(1, 2, 3));

the error message is hard to diagnose. See the attached foo.cpp for an example.

In the foo.cpp example, the lines that pass the wrong argument via explicit
construction ([5] and [7]) tell the user exactly what the problem is:

    foo.cpp:12:21: note: candidates are:
    foo.cpp:2:14: note: Foo::Foo(int, float, Bar)
    foo.cpp:2:14: note:   no known conversion for argument 3 from ‘int’ to
‘Bar’

whereas the lines that pass the arguments using the initializer list syntax are
impossible to diagnose from the error message:

    foo.cpp:18:21: error: invalid initialization of reference of type ‘const
Foo&’ from expression of type ‘<brace-enclosed initializer list>’
    foo.cpp:4:6: error: in passing argument 1 of ‘void foo(const Foo&)’



More information about the Gcc-bugs mailing list