https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85691
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |DUPLICATE --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Did you forget to enable warnings? GCC warns about test2 but not test: $ g++ -Wall -c 85691.cc 85691.cc: In constructor ‘test2::test2(int)’: 85691.cc:14:13: warning: ‘test2::data’ will be initialized after [-Wreorder] int data; ^~~~ 85691.cc:13:13: warning: ‘int test2::x’ [-Wreorder] int x; ^ 85691.cc:16:9: warning: when initialized here [-Wreorder] test2(int o) : data(o), x(data) { } ^~~~~ Clang has the same behaviour for -Wreorder, but it additionally warns about test::data with -Wuninitialized: 85691.cc:4:17: warning: field 'data' is uninitialized when used here [-Wuninitialized] int x = data; ^ 85691.cc:7:9: note: during field initialization in this constructor test(int o) : data(o) { } ^ 85691.cc:16:24: warning: field 'data' will be initialized after field 'x' [-Wreorder] test2(int o) : data(o), x(data) { } ^ 85691.cc:16:35: warning: field 'data' is uninitialized when used here [-Wuninitialized] test2(int o) : data(o), x(data) { } ^ 3 warnings generated. We already have Bug 19808 covering this. *** This bug has been marked as a duplicate of bug 19808 ***