昨日のイニシャライズ順番問題

やっぱりワーニングが出る。どーでもいいっちゃどーでもいいんだけど

noya@supphire ~
$ g++ -v
(中略)
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)

noya@supphire ~
$ g++ -Wall test.cpp
test.cpp: In constructor `Piyo::Piyo(int, int, int)':
test.cpp:12: warning: `Piyo::moke' will be initialized after
test.cpp:12: warning: `int Piyo::hoge'
test.cpp:10: warning: when initialized here

とりあえず手元のCygwin上で再現。 ちなみに最初にこの現象が起こったgccのバージョンは4.1.0ですた。

ソースはこんな感じ

class Hoge{
	public:
		Hoge(int h,int p,int m):hoge(h),piyo(p),moke(m){};
	private:
		int hoge,piyo,moke;
};

class Piyo{
	public:
		Piyo(int p,int m,int h):piyo(p),moke(m),hoge(h){};
	private:
		int hoge,piyo,moke;
};

int main(void){
	Hoge hoge(1,2,3);
	Piyo piyo(2,3,1);
	return 0;
}

んーむ、不思議。