User account creation filtered due to spam.

Bug 11554 - [3.3/3.4 Regression] Warning about reordering of initializers doesn't mention location of constructor
Summary: [3.3/3.4 Regression] Warning about reordering of initializers doesn't mention...
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.3.3
Assignee: Not yet assigned to anyone
Keywords: diagnostic
Depends on:
Reported: 2003-07-16 23:32 UTC by Wolfgang Bangerth
Modified: 2004-01-17 04:22 UTC (History)
3 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-16 23:41:51


Note You need to log in before you can comment on or make changes to this bug.
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 In constructor `Y::Y()': warning: `Y::i2' will be initialized after 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.

Comment 1 Andrew 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: In constructor `Y::Y()': warning: member initializers for `int Y::i2' warning:   and `int Y::i1' warning:   will be re-ordered to match declaration order
I do not know why this was changed.
Comment 2 Andrew 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 
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 5 CVS Commits 2003-12-22 06:07:06 UTC
Subject: Bug 11554

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	2003-12-22 06:07:02

Modified files:
	gcc/cp         : ChangeLog init.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: ctor-init-1.C 

Log message:
	PR c++/11554
	* init.c (sort_mem_initializers): Add warning.
	PR c++/11554
	* testsuite/g++.dg/warn/ctor-init-1.C: New test.


Comment 7 Mark Mitchell 2003-12-22 06:15:18 UTC
Fixed in GCC 3.3.3 and GCC 3.4.