Bug 465292

Summary: G++ variadic templates not demangled
Product: [Fedora] Fedora Reporter: Jan Kratochvil <jan.kratochvil>
Component: binutilsAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: medium    
Version: rawhideCC: drepper, jakub, jan.kratochvil
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-10-07 23:09:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Kratochvil 2008-10-02 16:25:37 UTC
There seems to be a problem with the demangler in F9 when the new
variadic template feature of g++ is used.  Compile the code below and
you'll find this:

0000000000400596 W int f<double, int>(double, int __variadic)
0000000000400584 W _Z1fIiEiT_U10__variadicT0_
00000000004005d0 W int f<int, double, int>(int, double __variadic)

The second line should also be demangled.  No idea what it is but my
guess is no _Z* symbol should be left.

int f()
{
  return 0;
}

template <typename T, typename... U>
int f(T t, U... u)
{
  return (t ? 1 : 0) * sizeof...(U) + f(u...);
}

int
main()
{
  return f(1, 1.0, 2);
}

Comment 1 Jan Kratochvil 2008-10-07 23:09:00 UTC
Got fixed upstream:
http://gcc.gnu.org/ml/gcc-patches/2008-09/msg00729.html
http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00189.html

GCC now even produces different mangled names:
GNU C++ (GCC) version 4.4.0 20081007 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.4.0 20081007 (experimental), GMP version 4.2.2, MPFR version 2.3.1.

00000000004005c3 w F .text 000000000000003f _Z1fIdIiEEiT_DpT0_
0000000000400602 w F .text 0000000000000012 _Z1fIiIEEiT_DpT0_ 
0000000000400584 w F .text 000000000000003f _Z1fIiIdiEEiT_DpT0_

00000000004005c3 w F .text 000000000000003f int f<double, int>(double, int) 
0000000000400602 w F .text 0000000000000012 int f<int, >(int, )
0000000000400584 w F .text 000000000000003f int f<int, double, int>(int, double, int)

2008-09-09  Jason Merrill  <jason>

	* include/demangle.h (enum demangle_component_type): Add
	DEMANGLE_COMPONENT_DECLTYPE.
	* libiberty/cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_DECLTYPE.
	(d_make_comp): Likewise.
	(cplus_demangle_type): Handle decltype and DFP types.
	(cplus_demangle_operators): Call operator takes 2 args.
	(cplus_demangle_builtin_types): Add DFP types.
	(d_exprlist): New fn.
	(d_expression): Handle parm placeholders, T() and calls.
	(d_print_comp): Handle decltype, T() and calls.
	* libiberty/testsuite/demangle-expected: Test the above.

2008-10-06  Jason Merrill  <jason>

gcc/cp/:
	PR c++/37376, other mangling issues
	* mangle.c (write_type): Update TYPE_PACK_EXPANSION mangling.
	(write_member_name): Break out from...
	(write_expression): ...here.  Handle dependent COMPONENT_REF.
	(write_template_arg): Wrap an argument pack in 'I'/'E'.
	(write_builtin_type): Update char16/32_t mangling.
	(write_nested_name, write_prefix): Don't forget template args
	for typename types.
	* operators.def: Add ARROW_EXPR, update COMPONENT_REF and 
	EXPR_PACK_EXPANSION.
libstdc++-v3/:
	* config/abi/pre/gnu.ver: Update char16/32_t manglings.
include/:
	* demangle.h (enum demangle_component_type): Add
	DEMANGLE_COMPONENT_PACK_EXPANSION.
libiberty/:
	* cp-demangle.c (struct d_print_info): Add pack_index.
	(d_dump): Add DEMANGLE_COMPONENT_PACK_EXPANSION.
	(d_make_comp): Likewise.  DEMANGLE_COMPONENT_ARGLIST and
	DEMANGLE_COMPONENT_TEMPLATE_ARGLIST can have two null args.
	(cplus_demangle_builtin_types): Add char16/32_t.
	(cplus_demangle_type): Recognize them.
	(d_template_args): Handle empty argument packs.
	(d_template_arg): Handle argument packs.
	(d_expression): Handle dependent name.
	(d_index_template_argument): New fn.
	(d_lookup_template_argument): New fn.
	(d_find_pack, d_pack_length): New fn.
	(d_print_subexpr): Split out...
	(d_print_comp): ...from here.  Use d_*_template_argument.
	Handle empty arg lists.  Support pack expansions.
	* cp-demangle.h (D_BUILTIN_TYPE_COUNT): Increase to 32.

  2008-09-09  Jason Merrill  <jason>
  
  	* cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_DECLTYPE.