11554 – [3.3/3.4 Regression] Warning about reordering of initializers doesn't mention location of constructor (original) (raw)
Description Wolfgang Bangerth 2003-07-16 23:32:17 UTC
When one accidentally orders initializers of member variables in another order than the one they appear in the class declaration, one gets a warning about this. However, this warning doesn't state where the problem is:
struct Y { Y (); int i1, i2; };
Y::Y () : i2(0), i1(0) {}
parameter-estimation/me-uncertainty> c++ -Wall -c x.cc
x.cc: In constructor Y::Y()': x.cc:3: warning: Y::i2' will be initialized after
x.cc:3: warning: `int Y::i1'
So this gives the location where i1 and i2 are declared, but it doesn't show where the problem really is, namely in the definition of the constructor, or more exactly: in its member initializer list, which would be in line 6. This can become a little confusing if one has a class with more than one constructor.
W.
Comment 1 Drea Pinski 2003-07-16 23:41:50 UTC
I can confirm this on 3.3.1 (20030707) and the mainline (20030716), but on 3.2.3, gcc gives the
line number:
pr11554.cc: In constructor Y::Y()': [pr11554](show%5Fbug.cgi?id=11554 "RESOLVED FIXED - [3.3/3.4 Regression] Warning about reordering of initializers doesn't mention location of constructor").cc:3: warning: member initializers for int Y::i2'
pr11554.cc:3: warning: and `int Y::i1'
pr11554.cc:6: warning: will be re-ordered to match declaration order
I do not know why this was changed.
Comment 2 Drea Pinski 2003-08-05 05:15:43 UTC
I found the history of why this change, it was changed to fix an ICE on valid code, PR 7188. Mark your patch which fixed that PR also removed the location of inititalizers, did you mean to do that?
Comment 3 Mark Mitchell 2003-10-16 09:22:29 UTC
Postponed until GCC 3.3.3.
Comment 4 Gabriel Dos Reis 2003-12-21 20:45:36 UTC
Mark -- Do you have plan for this regression?
-- Gaby
Comment 7 Mark Mitchell 2003-12-22 06:15:18 UTC
Fixed in GCC 3.3.3 and GCC 3.4.