[Bug c++/58977] New: C++11 uniform initialization syntax causes error
drtwox at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Nov 3 01:54:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58977
Bug ID: 58977
Summary: C++11 uniform initialization syntax causes error
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: drtwox at gmail dot com
Code example and compiler output explains all:
#include <fstream>
struct foo
{
foo( std::fstream& stream )
: stream_{ stream } // <-- Here's the problem
{}
std::fstream& stream_;
};
int main()
{
std::fstream stream;
foo f{ stream };
}
$ g++ --version
g++ (Ubuntu/Linaro 4.8.1-10ubuntu8) 4.8.1
$ g++ brace.cpp -std=c++11 -Wall -Wextra
brace.cpp: In constructor ‘foo::foo(std::fstream&)’:
brace.cpp:6:21: error: invalid initialization of non-const reference of type
‘std::fstream& {aka std::basic_fstream<char>&}’ from an rvalue of type
‘<brace-enclosed initializer list>’
: stream_{ stream } // <-- Here's the problem
More information about the Gcc-bugs
mailing list