Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-10 Thread Jonathan Wakely
On 10 November 2011 20:17, Jason Merrill wrote: > On 11/10/2011 03:10 PM, Jason Merrill wrote: >> >> On 11/10/2011 02:48 PM, Jonathan Wakely wrote: >>> >>> +warn_missing_meminits (tree type, tree cons) >>> +{ >>> + tree mem_inits = sort_mem_initializers (type, NULL_TREE); >>> + while (mem_inits) >>

Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-10 Thread Jason Merrill
On 11/10/2011 03:10 PM, Jason Merrill wrote: On 11/10/2011 02:48 PM, Jonathan Wakely wrote: +warn_missing_meminits (tree type, tree cons) +{ + tree mem_inits = sort_mem_initializers (type, NULL_TREE); + while (mem_inits) + { + tree member = TREE_PURPOSE (mem_inits); + /* TODO do not warn if brac

Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-10 Thread Jason Merrill
On 11/10/2011 02:48 PM, Jonathan Wakely wrote: +warn_missing_meminits (tree type, tree cons) +{ + tree mem_inits = sort_mem_initializers (type, NULL_TREE); + while (mem_inits) +{ + tree member = TREE_PURPOSE (mem_inits); + /* TODO do not warn if brace-or-equal-initializer */ +

Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-10 Thread Jonathan Wakely
On 7 November 2011 21:47, Jason Merrill wrote: > On 11/07/2011 04:43 PM, Jonathan Wakely wrote: >> >> Unfortunately this doesn't work very well in C++11 mode, as defaulted >> constructors don't cause warnings when they should do e.g. > > Maybe check this in defaulted_late_check? I tried that (atta

Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-07 Thread Gabriel Dos Reis
On Mon, Nov 7, 2011 at 4:39 PM, Jason Merrill wrote: > On 11/07/2011 05:38 PM, Gabriel Dos Reis wrote: >>> >>> struct C >>> { >>>  int i; >>>  C() = default; >>> }; >> >> so the defaulted constructor does not initialize C::i? > > No, it doesn't.  value-initialization of a C will initialize it, but

Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-07 Thread Jonathan Wakely
On 7 November 2011 22:38, Gabriel Dos Reis wrote: >> Unfortunately this doesn't work very well in C++11 mode, as defaulted >> constructors don't cause warnings when they should do e.g. >> >> struct C >> { >>  int i; >>  C() = default; >> }; >> >> This doesn't produce the same warning as C() {} even

Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-07 Thread Jason Merrill
On 11/07/2011 05:38 PM, Gabriel Dos Reis wrote: struct C { int i; C() = default; }; so the defaulted constructor does not initialize C::i? No, it doesn't. value-initialization of a C will initialize it, but not default-initialization. Jason

Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-07 Thread Gabriel Dos Reis
On Mon, Nov 7, 2011 at 3:43 PM, Jonathan Wakely wrote: > This is a new version of my -Wmeminit patch, first posted to PR c++/2972. > > Jason suggested combining the Wmeminit warning with the adjacent > Weffc++ one which I agree with.  The advice in the Effective C++ book > actually says not to lea

Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-07 Thread Jason Merrill
On 11/07/2011 04:43 PM, Jonathan Wakely wrote: Unfortunately this doesn't work very well in C++11 mode, as defaulted constructors don't cause warnings when they should do e.g. Maybe check this in defaulted_late_check? Jason

[patch] c++/2972 warn when ctor-initializer leaves uninitialized data

2011-11-07 Thread Jonathan Wakely
This is a new version of my -Wmeminit patch, first posted to PR c++/2972. Jason suggested combining the Wmeminit warning with the adjacent Weffc++ one which I agree with. The advice in the Effective C++ book actually says not to leave members uninitialized, rather than saying *all* members must h