This is the mail archive of the gcc-patches@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] | |
On 12/08/2016 01:28 PM, Marek Polacek wrote:
On Thu, Dec 08, 2016 at 02:56:56PM -0500, Nathan Sidwell wrote:On 12/08/2016 01:05 PM, Jason Merrill wrote:If the problem is the member initializer, we can diagnose that directly rather than wait until we're in a constructor.What about: struct Foo { int a; char ary[]; Foo () : ary ("bob"){} }; ? That ICEs in the same way.My patch would make GCC to reject this too, but the new 'else' needs to be removed from the patch, i.e.
Clang accepts this test case although it does reject the originally submitted test case with the messages below. I think GCC should accept the latter case for compatibility. If it is accepted then rejecting the original test case will make the array initialization irregular. I think it would be nice if they both could accepted but I don't know how much work it would be to make it work. Martint.C:4:12: warning: in-class initialization of non-static data member is a C++11
extension [-Wc++11-extensions]
char a[] = "foo";
^
t.C:4:12: error: array bound cannot be deduced from an in-class initializer
t.C:3:8: warning: private field 'b' is not used [-Wunused-private-field]
bool b;
^
t.C:4:8: warning: private field 'a' is not used [-Wunused-private-field]
char a[] = "foo";
^
3 warnings and 1 error generated.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |