[Bug c++/53494] [4.7/4.8 Regression] ICE with invalid initializer list
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Tue May 29 22:14:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53494
--- Comment #14 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-05-29 21:16:57 UTC ---
(In reply to comment #13)
> Am I interpreting correctly that double braces are /required/ for std::array
> init lists but only when the subtype has has a multivariable initializer too?
I must agree that the compiler behaviour does not look correct to me. Initially
I thought that the reason is due to the fact, that brace-elision does not apply
here, but then I noticed that this code does not compile either:
struct pair
{
pair(const char*, int) { }
};
struct array_p
{
pair data[1];
};
array_p a = { { "smile", 1 } };
Here we have definitively brace elision in action, but I get the same error as
from Jonathan's example. My impression is that the compiler incorrectly does
not see the brace-elision case here.
Here is an example that works (with an expected [-Wmissing-braces] warning):
struct string
{
string(const char*) { }
};
struct array_s
{
string data[1];
};
array_s b{ "smile" };
From this I see that gcc already implements
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1270
so I must conclude that the compiler should also accept the original example.
More information about the Gcc-bugs
mailing list