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...
Status: RESOLVED FIXED
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
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2003-07-16 23:32 UTC by Wolfgang Bangerth
Modified: 2004-01-17 04:22 UTC (History)
3 users (show)

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


Attachments

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 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 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:
pr11554.cc: In constructor `Y::Y()':
pr11554.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 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 
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 5 CVS Commits 2003-12-22 06:07:06 UTC
Subject: Bug 11554

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	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.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3826&r2=1.3827
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.353&r2=1.354
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3294&r2=1.3295
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/ctor-init-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

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