www.digitalmars.com         C & C++   DMDScript  

c++ - C++ template mangling DMC vs VS

reply "IgorStepanov" <wazar mail.ru> writes:
I've tried to compile next code:

struct Goo
	template<class X>
	struct Boo
		template<class Y>
		struct Xoo
			Y* v;
		X* v;

	void bar2(Boo<void>::Xoo<int> arg1);

void Goo::bar2(Goo::Boo<void>::Xoo<int> arg1)

Visual Studio mangle Goo::bar2 as
"?bar2 Goo  QAEXU?$Xoo H ?$Boo X 1  Z"
It's expected:
?$Xoo H  : - ::Xoo<int>
?$Boo X  : - ::Boo<void>
1        : - Goo (saved early)

DMC mangle Goo::bar2 as
"?bar2 Goo  QAEXU?$Xoo ?$Boo Goo X Goo H ?$Boo Goo X 1  Z"
?$Xoo ?$Boo Goo X Goo H  :- ::Xoo<int>
?$Boo Goo X              :- ::Boo<void>
1                        : - Goo (saved early)
Ergo: DMC writes all parent names for each part of templated name.

Is this behaviour expected and desirable or it is bug?
(I'm writing C++ mangler for DMD now and I need to know: should I 
create special cases for DMC and VS or I can use VS mangling 
scheme and wait when this issue will be fixed in DMC?)
Jul 07 2013
parent "IgorStepanov" <wazar mail.ru> writes:
Also: VS mangler substitute repeated templated parts of name, DMC 
void gun(P1::Mem<int>, P2::Mem<int>){}
VS: "?gun  YAXU?$Mem H P1  U1P2   Z"

Attention: VS has substituted second Mem<int> with "1"

DMC: "gun  YAXU?$Mem P1 H P1  U?$Mem P2 H P2   "
Jul 07 2013