[Bug c++/40308] New: Brace initialization fails for member initializers in constructor for class templates
public at alisdairm dot net
gcc-bugzilla@gcc.gnu.org
Sat May 30 14:47:00 GMT 2009
Tested against MinGW 4.4.0
The following code fails to compile, with the two specializations yielding
different error messages.
Test code:
template< typename T >
struct test {
test() : data{} {}
T data;
};
int main()
{
test<int> x;
test<int*> y;
return 0;
}
Compiler output:
||=== BraceInitBug01, Debug ===|
main.cpp||In constructor 'test<T>::test() [with T = int]':|
main.cpp|10|instantiated from here|
main.cpp|3|error: aggregate value used where an integer was expected|
main.cpp||In constructor 'test<T>::test() [with T = int*]':|
main.cpp|11|instantiated from here|
main.cpp|3|error: cannot convert '<brace-enclosed initializer list>()' from
type '<brace-enclosed initializer list>' to type 'int*'|
||=== Build finished: 2 errors, 0 warnings ===|
--
Summary: Brace initialization fails for member initializers in
constructor for class templates
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: public at alisdairm dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40308
More information about the Gcc-bugs
mailing list