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++/53333] New: Initializer lists in std=c++03 mode must be an error


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

             Bug #: 53333
           Summary: Initializer lists in std=c++03 mode must be an error
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: fpelliccioni@gmail.com


Hi,

The following code, compiled with -std=c++03 option, emits a warning instead of
an error.

Regards,
Fernando.


//Begin code
#include <string>
#include <utility>

void foo( std::string ) {}
void foo( std::pair<std::string, std::string> ) {}

int main( /* int argc, char* argv[] */ )
{
    foo( {"k0", "v0"} );

  return 0;
}

// End code



#g++ -std=c++03 gcc_warning.cpp
gcc_warning.cpp: In function 'int main()':
gcc_warning.cpp:9:5: warning: extended initializer lists only available with
-std=c++11 or -std=gnu++11 [enabled by default]
gcc_warning.cpp:9:20: error: call of overloaded 'foo(<brace-enclosed
initializer list>)' is ambiguous
gcc_warning.cpp:9:20: note: candidates are:
gcc_warning.cpp:4:6: note: void foo(std::string)
gcc_warning.cpp:5:6: note: void foo(std::pair<std::basic_string<char>,
std::basic_string<char> >)


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